CHEF_AND_TDM EDITORAL

PROBLEM LINK
PREREQUISITES
MATH

SOLUTION:
Given A(Chef’s Score) B(Team score), our task is to find ranking of chef, we can find the ranking of chef by following the instruction given over there:

//ABHILASH'S TEMPLATE
#include<bits/stdc++.h>
using namespace std;

void solve()
{
  int a, b; cin >> a >> b;
  if (a>=(b+1)/2)
  {
    cout << "TOP\n";
    return;
  }
  if (a <(b/4))
  {
    cout << "BOTTOM\n";
  }
  else
  {
    cout << "MIDDLE\n";
  }

}

int main()
{
  int t = 1;
  cin >> t;

  for (int tt = 1; tt <= t; tt++)
  {
    // cout << "Case #" << tt << ": ";
    solve();
  }

}