#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int N = 250;
int x[N];
bool solvetype() {
  double sum = 0;
  for (int i = (0); i < (N); ++i) sum += x[i];
  double avg = sum / N;
  double sumsq = 0;
  for (int i = (0); i < (N); ++i) sumsq += (x[i] - avg) * (x[i] - avg);
  double var = sumsq / (N - 1);
  double res = 3 * var / avg / avg;
  return res > .6;
}
int solve() {
  if (solvetype()) {
    int ret = x[0];
    for (int i = (0); i < (N); ++i) ret = max(ret, x[i]);
    return ret / 2;
  } else {
    double sum = 0;
    for (int i = (0); i < (N); ++i) sum += x[i];
    double avg = sum / N;
    return (int)floor(avg + .5);
  }
}
void run() {
  for (int i = (0); i < (N); ++i) scanf("%d", &x[i]);
  printf("%d\n", solve());
}
void test(int have, int want) {
  printf("%.9lf (have=%d want=%d)\n", 1.0 * have / want, have, want);
}
void testunif() {
  int P = rand() % (1000 - 10 + 1) + 10;
  for (int i = (0); i < (N); ++i) x[i] = rand() % (2 * P + 1);
  test(solve(), P);
}
void testpoisson() {
  int P = rand() % (1000 - 10 + 1) + 10;
  double L = exp(-1.0 * P);
  for (int i = (0); i < (N); ++i) {
    int k = 0;
    double p = 1;
    do {
      ++k;
      double u = 1.0 * rand() / RAND_MAX;
      p *= u;
    } while (p > L);
    x[i] = k - 1;
  }
  test(solve(), P);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) run();
  return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int N = 250;
int x[N];
bool solvetype() {
  double sum = 0;
  for (int i = (0); i < (N); ++i) sum += x[i];
  double avg = sum / N;
  double sumsq = 0;
  for (int i = (0); i < (N); ++i) sumsq += (x[i] - avg) * (x[i] - avg);
  double var = sumsq / (N - 1);
  double res = 3 * var / avg / avg;
  return res > .6;
}
int solve() {
  if (solvetype()) {
    int ret = x[0];
    for (int i = (0); i < (N); ++i) ret = max(ret, x[i]);
    return ret / 2;
  } else {
    double sum = 0;
    for (int i = (0); i < (N); ++i) sum += x[i];
    double avg = sum / N;
    return (int)floor(avg + .5);
  }
}
void run() {
  for (int i = (0); i < (N); ++i) scanf("%d", &x[i]);
  printf("%d\n", solve());
}
void test(int have, int want) {
  printf("%.9lf (have=%d want=%d)\n", 1.0 * have / want, have, want);
}
void testunif() {
  int P = rand() % (1000 - 10 + 1) + 10;
  for (int i = (0); i < (N); ++i) x[i] = rand() % (2 * P + 1);
  test(solve(), P);
}
void testpoisson() {
  int P = rand() % (1000 - 10 + 1) + 10;
  double L = exp(-1.0 * P);
  for (int i = (0); i < (N); ++i) {
    int k = 0;
    double p = 1;
    do {
      ++k;
      double u = 1.0 * rand() / RAND_MAX;
      p *= u;
    } while (p > L);
    x[i] = k - 1;
  }
  test(solve(), P);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) run();
  return 0;
}

```