Problem: Good job! Now that Heidi is able to distinguish between Poisson and uniform distributions, she is in a good position to actually estimate the populations.

Can you help Heidi estimate each village's population?

Input

Same as the easy version.

Output

Output one line per village, in the same order as provided in the input, containing your (integer) population estimate.

Your answer is considered correct if it is an integer that falls into the interval <image>, where P is the real population of the village, used to create the distribution (either Poisson or uniform) from which the marmots drew their answers.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long lis[333], n;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  while (n--) {
    for (int i = (0); i <= ((int)(250) - 1); i++) cin >> lis[i];
    int p25, p75;
    int cnt = 0;
    sort(lis, lis + 250);
    p25 = max(1LL, lis[62]);
    p75 = max(1LL, lis[187]);
    if (1.0 * p75 / p25 > 1.9) {
      cout << (lis[0] + lis[249]) / 2;
    } else {
      cout << (lis[124] + lis[125]) / 2;
    }
    cout << endl;
  }
}