func_code_string: #include <bits/stdc++.h>   using namespace std;   struct si {     long long x, s;   };   long long t[2][6] = {0}, k[200] = {0}, p[6][7] = {0}, sp = 0;   vector<si> s;   bool cmp(si a, si b) { return a.x < b.x; }   int main() {     long long n, q, p, x, y, a, m;     si S;     cin >> n;     m = n;     for (int i = 0; i < 5; i++) {       cin >> t[0][i];       if (t[0][i] != -1) k[i]++;     }     for (int i = 0; i < 5; i++) {       cin >> t[1][i];       if (t[1][i] != -1) k[i]++;     }     while (n > 2) {       n--;       for (int i = 0; i < 5; i++) {         cin >> x;         if (x != -1) k[i]++;       }     }     n = m;     for (int i = 0; i < 5; i++)       if (t[0][i] != -1 || t[1][i] != -1) {         if (t[0][i] == -1) {           if (k[i] * 2 > n) {             S.x = 2 * k[i] - n;             S.s = -(500 - 2 * t[1][i]);             s.push_back(S);           }           if (k[i] * 4 > n) {             S.x = 4 * k[i] - n;             S.s = -(500 - 2 * t[1][i]);             s.push_back(S);           }           if (k[i] * 8 > n) {             S.x = 8 * k[i] - n;             S.s = -(500 - 2 * t[1][i]);             s.push_back(S);           }           if (k[i] * 16 > n) {             S.x = 16 * k[i] - n;             S.s = -(500 - 2 * t[1][i]);             s.push_back(S);           }           if (k[i] * 32 > n) {             S.x = 32 * k[i] - n;             S.s = -(500 - 2 * t[1][i]);             s.push_back(S);           }           sp -= (500 - 2 * t[1][i]);           if (k[i] * 2 <= n) {             sp -= (500 - 2 * t[1][i]);           }           if (k[i] * 4 <= n) {             sp -= (500 - 2 * t[1][i]);           }           if (k[i] * 8 <= n) {             sp -= (500 - 2 * t[1][i]);           }           if (k[i] * 16 <= n) {             sp -= (500 - 2 * t[1][i]);           }           if (k[i] * 32 <= n) {             sp -= (500 - 2 * t[1][i]);           }         } else if (t[1][i] == -1) {           if (k[i] * 2 > n) {             S.x = 2 * k[i] - n;             S.s = (500 - 2 * t[0][i]);             s.push_back(S);           }           if (k[i] * 4 > n) {             S.x = 4 * k[i] - n;             S.s = (500 - 2 * t[0][i]);             s.push_back(S);           }           if (k[i] * 8 > n) {             S.x = 8 * k[i] - n;             S.s = (500 - 2 * t[0][i]);             s.push_back(S);           }           if (k[i] * 16 > n) {             S.x = 16 * k[i] - n;             S.s = (500 - 2 * t[0][i]);             s.push_back(S);           }           if (k[i] * 32 > n) {             S.x = 32 * k[i] - n;             S.s = (500 - 2 * t[0][i]);             s.push_back(S);           }           sp += (500 - 2 * t[0][i]);           if (k[i] * 2 <= n) {             sp += (500 - 2 * t[0][i]);           }           if (k[i] * 4 <= n) {             sp += (500 - 2 * t[0][i]);           }           if (k[i] * 8 <= n) {             sp += (500 - 2 * t[0][i]);           }           if (k[i] * 16 <= n) {             sp += (500 - 2 * t[0][i]);           }           if (k[i] * 32 <= n) {             sp += (500 - 2 * t[0][i]);           }         } else if (t[0][i] <= t[1][i]) {           if (k[i] * 2 > n) {             S.x = 2 * k[i] - n;             S.s = (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);             s.push_back(S);           }           if (k[i] * 4 > n) {             S.x = 4 * k[i] - n;             S.s = (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);             s.push_back(S);           }           if (k[i] * 8 > n) {             S.x = 8 * k[i] - n;             S.s = (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);             s.push_back(S);           }           if (k[i] * 16 > n) {             S.x = 16 * k[i] - n;             S.s = (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);             s.push_back(S);           }           if (k[i] * 32 > n) {             S.x = 32 * k[i] - n;             S.s = (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);             s.push_back(S);           }           sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           if (k[i] * 2 <= n) {             sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           }           if (k[i] * 4 <= n) {             sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           }           if (k[i] * 8 <= n) {             sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           }           if (k[i] * 16 <= n) {             sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           }           if (k[i] * 32 <= n) {             sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           }         } else {           if (k[i] * 2 > n) {           }           if (2 * k[i] <= n) {             S.x = (n - 2 * k[i] + 2) / 2;             S.s = -((500 - 2 * t[0][i]) - (500 - 2 * t[1][i]));             s.push_back(S);           }           if (4 * k[i] <= n) {             S.x = (n - 4 * k[i] + 4) / 4;             S.s = -(500 - 2 * t[0][i]) + (500 - 2 * t[1][i]);             s.push_back(S);           }           if (k[i] * 8 <= n) {             S.x = (n - 8 * k[i] + 8) / 8;             S.s = -(500 - 2 * t[0][i]) + (500 - 2 * t[1][i]);             s.push_back(S);           }           if (k[i] * 16 <= n) {             S.x = (n - 16 * k[i] + 16) / 16;             S.s = -(500 - 2 * t[0][i]) + (500 - 2 * t[1][i]);             s.push_back(S);           }           sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           if (k[i] * 2 <= n) {             sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           }           if (k[i] * 4 <= n) {             sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           }           if (k[i] * 8 <= n) {             sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           }           if (k[i] * 16 <= n) {             sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           }           if (k[i] * 32 <= n) {             sp += (500 - 2 * t[0][i]) - (500 - 2 * t[1][i]);           }         }       }     sort(s.begin(), s.end(), cmp);     int i = 0;     while (sp <= 0 && i < s.size()) {       sp = sp + s[i].s;       i++;       while (i < s.size() && (i == 0 || s[i - 1].x == s[i].x)) {         sp = sp + s[i].s;         i++;       }     }     if (sp <= 0) {       cout << -1;       return 0;     }     if (i == 0)       cout << 0;     else       cout << s[i - 1].x;     return 0;   }   