malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int maxn = 1e6 + 5;   long long int power(long long int base, long long int exp) {     long long int res = 1;     while (exp) {       if (exp % 2) res *= base;       base *= base;       res %= mod;       base %= mod;       exp /= 2;     }     return res;   }   long long int x[2], y[2], val[2];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int i, n, a, b, c;     for (long long int j = 0; j < 2; j++) cin >> x[j] >> y[j];     cin >> n;     long long int ans = 0;     for (i = 1; i <= n; i++) {       cin >> a >> b >> c;       for (long long int j = 0; j < 2; j++) {         val[j] = -1;         if (a * x[j] + b * y[j] + c > 0) val[j] = 1;       }       if (val[1] > 0 && val[0] < 0) ans++;       if (val[1] < 0 && val[0] > 0) ans++;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const bound = 1e6 + 2, N = 2e5 + 1;   long long OO = 1e18;   double eps = 1e-6;   int oo = 1e9, mod = 1e9 + 7;   int n, m, s, app[N][2];   pair<int, int> par[N][2];   vector<int> adj[N], rev[N];   queue<pair<int, int> > q;   int vis[N];   void buildpath() {     puts( Win );     int cur = s, c = 1;     while (cur != -1) {       printf( %d  , cur);       pair<int, int> ne = par[cur][c];       cur = ne.first;       c = ne.second;     }   }   bool cyc(int u) {     vis[u] = 2;     for (auto v : rev[u]) {       if (vis[v] == 2) return 1;       if (!vis[v] && cyc(v)) return 1;     }     vis[u] = 1;     return 0;   }   int main() {     scanf( %d%d , &n, &m);     for (int(i) = 1; (i) <= (n); (i)++) {       int sz;       scanf( %d , &sz);       if (!sz) {         q.push({i, 0});         app[i][0] = 1;         par[i][0] = {-1, -1};       }       while (sz--) {         int a;         scanf( %d , &a);         adj[a].push_back(i);         rev[i].push_back(a);       }     }     scanf( %d , &s);     while (!q.empty()) {       pair<int, int> cur = q.front();       q.pop();       for (auto v : adj[cur.first]) {         int cost = cur.second + 1;         int md = cost % 2;         if (app[v][md]) continue;         app[v][md] = 1;         par[v][md] = {cur.first, cur.second};         if (v == s && md) {           buildpath();           return 0;         }         q.push({v, cost % 2});       }     }     if (cyc(s)) {       puts( Draw );       return 0;     }     puts( Lose );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[25][25][5], ans, n, t;   int main() {     cin >> n >> t;     for (int i = 1; i <= 4; i++)       for (int j = i + 1; j <= 4; j++) dp[2][1][j]++;     for (int i = 3; i <= n; i++)       for (int j = 1; j <= t * 2; j++)         for (int k = 1; k <= 4; k++) {           if (j & 1)             for (int l = 1; l < k; l++)               dp[i][j][k] += dp[i - 1][j][l] + dp[i - 1][j - 1][l];           else             for (int l = k + 1; l <= 4; l++)               dp[i][j][k] += dp[i - 1][j][l] + dp[i - 1][j - 1][l];         }     for (int i = 1; i <= 4; i++) ans += dp[n][t * 2][i];     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n;     cin >> t;     while (t--) {       cin >> n;       int a = 0, b = 0, k = 2;       for (int i = 0; i < n / 2 - 1; i++) {         a += k;         k *= 2;       }       for (int i = 0; i < n / 2; i++) {         b += k;         k *= 2;       }       a += k;       cout << abs(a - b) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int k, t, state[16];   unordered_map<unsigned long long, long long> M[10];   unsigned long long tobeull(int state[]) {     int tmp[16] = {         0,     };     unsigned long long ret = 0;     for (int i = 0; i < 16; i++) tmp[i] = state[i];     sort(tmp, tmp + 16);     for (int i = 0; i < 16; i++) {       ret |= (tmp[i] << (i * 4));     }     return ret;   }   long long dp(int len, int state[]) {     if (len == 0) {       return 1;     }     auto it = M[len].emplace(tobeull(state), 0);     if (it.second) {       long long ret = 0;       for (int i = 0; i < 16; i++) {         if (state[i] == t) continue;         state[i]++;         ret += dp(len - 1, state);         state[i]--;       }       it.first->second = ret;       return it.first->second;     } else       return it.first->second;   }   int main() {     scanf( %d %d , &k, &t);     if (k <= 15) {       printf( %lx , k);       return 0;     }     int mylen = 1;     state[15]++;     long long rem = 0;     while (1) {       long long key = dp(mylen - 1, state) * (long long)15;       if (rem + key >= k) {         break;       } else         rem += key;       ++mylen;     }     int st = 1;     state[15] = 0;     for (int digit = 1; digit <= mylen; digit++) {       long long rem = 0;       if (st == 1) {         state[15] = 1;         for (int ite = mylen - 2; ite >= 0; ite--)           rem += dp(ite, state) * (long long)15;         state[15] = 0;       }       for (int num = st; num < 16; num++) {         if (state[num] == t) continue;         state[num]++;         long long cnt = dp(mylen - digit, state);         if (rem + cnt >= k) {           printf( %x , num);           break;         } else {           rem += cnt;           state[num]--;         }       }       k -= rem;       st = 0;     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, ans = -2;     cin >> n;     vector<int> v(n);     for (auto &a : v) cin >> a;     vector<int> max_ele_index;     int maxx = 0;     for (auto a : v) maxx = max(a, maxx);     for (int i = 0; i < n; i++)       if (v[i] == maxx) max_ele_index.push_back(i);     if (v[0] == maxx and v[1] != maxx) {       cout << 1 <<   n ;       return;     }     if (v[0] != maxx and v[1] == maxx) {       cout << 2 <<   n ;       return;     }     if (v[n - 1] == maxx and v[n - 2] != maxx) {       cout << n <<   n ;       return;     }     for (int i = 1; i < n - 1; i++)       if (v[i] == maxx and (v[i - 1] != maxx or v[i + 1] != maxx)) {         ans = i;         break;       }     cout << ans + 1 <<   n ;   }   int main() {     int t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int a[5100], b[5100];   long long c[5100];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       b[i] = a[i];     }     sort(b, b + n);     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) {         int d = b[j] - a[i];         if (d > 0)           c[j] = min(c[j - 1], d + c[j]);         else           c[j] -= d;       }     long long ans = c[0];     while (--n)       if (ans > c[n]) ans = c[n];     cout << ans << endl;   }
#include <bits/stdc++.h>   #pragma hdrstop   #pragma argsused   using namespace std;   int main(int argc, char* argv[]) {     int i, j, resp, resn, resv, resl, res, n, a, b;     vector<int> x, y;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d %d , &a, &b);       x.push_back(a);       y.push_back(b);     }     res = 0;     for (i = 0; i < n; i++) {       resv = 0;       resn = 0;       resp = 0;       resl = 0;       for (j = 0; j < n; j++) {         if (i != j) {           if (x[i] == x[j] && y[i] > y[j])             resn++;           else if (x[i] == x[j] && y[i] < y[j])             resv++;           else if (x[i] > x[j] && y[i] == y[j])             resl++;           else if (x[i] < x[j] && y[i] == y[j])             resp++;         }         if (resp != 0 && resl != 0 && resv != 0 && resn != 0) {           res++;           break;         }       }     }     printf( %d , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     long long d;     cin >> n >> d;     vector<long long> v;     long long x;     for (int i = 0; i < n; i++) {       cin >> x;       v.push_back(x);     }     int count = 0;     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         if (v[i] - v[j] >= 0 && v[i] - v[j] <= d)           count++;         else if (v[j] - v[i] >= 0 && v[j] - v[i] <= d)           count++;       }     }     cout << count * 2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return a * b / gcd(a, b); }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> k;     vector<int> c(n);     for (int &x : c) cin >> x;     long long cur = 1;     for (int &x : c) {       cur = gcd(k, lcm(cur, x));     }     if (cur == k) {       cout <<  Yes n ;     } else {       cout <<  No n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[1111][1111];   int d[1111][1111];   queue<pair<int, int> > Q;   vector<pair<int, int> > v;   int n, m, lim;   int dx[4] = {1, 0, -1, 0};   int dy[4] = {0, 1, 0, -1};   void check(int x, int y, int z) {     if (x < 0 || x >= n || y < 0 || y >= m) return;     if (s[x][y] ==  T ) return;     if (s[x][y] ==  S ) lim = z;     d[x][y] = z;     if ( 0  <= s[x][y] && s[x][y] <=  9 )       v.push_back(make_pair(s[x][y] -  0 , z));     s[x][y] =  T ;     Q.push(make_pair(x, y));   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) scanf( %s , s[i]);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (s[i][j] ==  E ) Q.push(make_pair(i, j));     while (!Q.empty()) {       pair<int, int> now = Q.front(), tmp;       Q.pop();       for (int dir = 0; dir < 4; dir++)         check(now.first + dx[dir], now.second + dy[dir],               d[now.first][now.second] + 1);     }     int ans = 0;     for (vector<pair<int, int> >::iterator ii = v.begin(); ii != v.end(); ii++)       if (ii->second <= lim) ans += ii->first;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct less_key {     bool operator()(pair<double, int64_t> p1, pair<double, int64_t> p2) {       return (p1.first > p2.first) ||              ((p1.first == p2.first) && (p1.second < p2.second));     }   };   struct pair_hash {     std::size_t operator()(const pair<int64_t, int64_t>& k) const {       return static_cast<size_t>(k.first ^ k.second);     }   };   const int64_t mod = 100000000007ll;   const int64_t inf = 10000000000000007ll;   const double eps = 0.00000001;   int64_t n, k;   string s;   int64_t amin[256];   int64_t amax[256];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> k;     cin >> s;     for (int64_t i = 0; i < s.size(); i++) {       if (!amin[s[i]]) {         amin[s[i]] = i + 1;       }       amax[s[i]] = i + 1;     }     set<pair<int64_t, int64_t> > q;     for (int64_t i =  A ; i <=  Z ; i++) {       if (amin[i]) {         q.insert({amin[i], 0});         q.insert({amax[i], 1});       }     }     int64_t z = 0;     for (auto i : q) {       if (i.second) {         z--;       } else {         z++;       }       if (z > k) {         cout <<  YES  << endl;         return 0;       }     }     cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     map<vector<int>, int> S;     for (int bit = 0; bit < (1 << 15); bit++) {       vector<int> b(n);       for (int i = 0; i < n; i++) {         int c = a[i] ^ bit;         for (int j = 0; j < 15; j++) {           if (c & (1 << j)) b[i]++;         }       }       vector<int> vec(n - 1);       for (int i = 1; i < n; i++) {         vec[i - 1] = b[i] - b[0];       }       S[vec] = bit;     }     for (int bit = 0; bit < (1 << 15); bit++) {       vector<int> b(n);       for (int i = 0; i < n; i++) {         int c = a[i] ^ (bit << 15);         for (int j = 15; j < 30; j++) {           if (c & (1 << j)) b[i]++;         }       }       vector<int> vec(n - 1);       for (int i = 1; i < n; i++) {         vec[i - 1] = b[0] - b[i];       }       if (S.find(vec) != S.end()) {         cout << (bit << 15) + S[vec] << endl;         return 0;       }     }     cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c;     cin >> a >> b >> c;     int Time = 0;     a -= 2;     int Turn = 2;     while (a > 0 || b > 0 || c > 0) {       if (Turn == 1) {         Time++;         a -= 2;         Turn = 2;       } else if (Turn == 2) {         Time++;         b -= 2;         Turn = 3;       } else if (Turn == 3) {         Time++;         c -= 2;         Turn = 1;       }     }     Time += 30;     cout << Time;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int x, int y) {     if (x == 0) return y;     return gcd(y % x, x);   }   int main() {     int n, m, x, g;     cin >> n >> m >> x;     g = x - 1;     for (int i = 1; i < n; ++i) {       scanf( %d , &x);       g = gcd(g, x - 1);     }     set<int> second;     int d = 1;     while (d * d <= g) {       if (g % d == 0) {         for (int p = 1; p * d <= m; p *= 2) second.insert(p * d);         for (int p = 1; p * (g / d) <= m; p *= 2) second.insert(p * (g / d));       }       ++d;     }     long long ans = 0;     for (set<int>::iterator it = second.begin(); it != second.end(); it++)       ans += m - (*it);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, f[6];     cin >> a >> b >> c;     f[0] = a + b + c;     f[1] = a + b * c;     f[2] = a * b + c;     f[3] = a * b * c;     f[4] = (a + b) * c;     f[5] = a * (b + c);     sort(f, f + 6);     cout << f[5];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long int> ar[100005];   long long int vis[100005];   long long int mi;   long long int val[100005];   void dfs(long long int a) {     vis[a] = 1;     mi = min(val[a], mi);     for (auto it : ar[a]) {       if (vis[it] == 0) {         dfs(it);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n, i, m, a, b, sum = 0;     cin >> n >> m;     for (i = 1; i <= n; i++) cin >> val[i];     for (i = 1; i <= m; i++) {       cin >> a >> b;       ar[a].push_back(b);       ar[b].push_back(a);     }     for (i = 1; i <= n; i++) {       if (vis[i] == 0) {         mi = INT_MAX;         dfs(i);         sum = sum + mi;       }     }     cout << sum <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int arr[10] = {0};     string s;     cin >> n >> s;     for (int i = 0; i < n; i++) arr[s[i] -  0 ]++;     if ((arr[1] || arr[2] || arr[3]) && (arr[7] || arr[0] || arr[9]) &&         (((arr[1] || arr[4] || arr[7]) && (arr[3] || arr[6] || arr[9])) ||          arr[0]))       cout <<  YES ;     else       cout <<  NO n ;   }
#include <bits/stdc++.h>   using namespace std;   int x[505], r[505];   int main() {     int i;     x[0] = 0;     r[0] = 1000000;     double dd;     int d;     for (i = 1; i <= 300; i++) {       r[i] = 300 - i + 1;       dd = 2 * sqrt(double(r[i - 1])) * sqrt(double(r[i]));       d = int(dd + 3);       x[i] = x[i - 1] + d;     }     x[301] = x[300] + 10000;     r[301] = 1000000;     printf( 302 );     for (i = 0; i < 302; i++) {       printf(  n%d %d , x[i], r[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200000 + 1];   int n;   int b[200000 + 1];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       b[a[i]] = 0;     }     int max = -1;     int k = 0;     int numb;     for (int i = n; i > 0; i--) {       k = 0;       if (b[a[i]] == 0) {         b[a[i]] = 1;         k = n - i;       }       if (k > max) {         max = k;         numb = a[i];       }     }     cout << numb;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int modulo = 1000000009;   long long A(int events, int days) {     if (events < days) return 0;     long long result = 1;     for (int e = events - 1; e >= days; --e) {       result *= e;       result %= modulo;     }     for (int i = 0; i < days; i++) {       result *= events;       result %= modulo;       --events;     }     return result;   }   int main() {     int n, w, b;     scanf( %i%i%i , &n, &w, &b);     long long result = 0;     for (int i = 2; i < n; i++) {       result += ((i - 1) * A(w, i)) % modulo * A(b, n - i);       result %= modulo;     }     printf( %i n , (int)result);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double p[100005], e1[100005], e2[100005];   int main() {     int n;     scanf( %d , &n);     for (register int i = 1; i <= n; ++i) scanf( %lf , p + i);     for (register int i = 1; i <= n; ++i) {       e1[i] = (e1[i - 1] + 1) * p[i];       e2[i] = e2[i - 1] + (e1[i - 1] + e1[i - 1] + 1) * p[i];     }     printf( %.15lf , e2[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = (int)3e3 + 5;   const int INF = (int)1e9;   const string T =  aeiou ;   int dp[MAXN], par[MAXN];   bool space[MAXN];   bool vowel[256];   string s;   int n;   bool bad(char a, char b, char c) {     if (a == b && b == c) {       return 0;     }     if (!vowel[a] && !vowel[b] && !vowel[c]) {       return 1;     }     return 0;   }   void solve() {     cin >> s;     n = s.size();     s =  #  + s;     for (char c : T) {       vowel[c] = 1;     }     for (int i = 1; i <= n; ++i) {       dp[i] = INF;     }     for (int l = 1; l <= n; ++l) {       bool good = 1;       for (int r = l; r <= n; ++r) {         if (r - 2 >= l && bad(s[r - 2], s[r - 1], s[r])) {           good = 0;           break;         }         if (dp[l - 1] + 1 < dp[r]) {           dp[r] = dp[l - 1] + 1;           par[r] = l - 1;         }       }     }     for (int v = n; v > 0; v = par[v]) {       space[v] = 1;     }     for (int i = 1; i <= n; ++i) {       printf( %c , s[i]);       if (space[i]) {         printf(   );       }     }   }   int main() {     int tt = 1;     while (tt--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int vis[6000];   int dp[5][100], mp[5][55], num[55];   int main() {     int n;     cin >> n;     for (int i = 1; i <= 2; i++)       for (int j = 1; j < n; j++) cin >> mp[i][j];     for (int i = 1; i <= n; i++) cin >> num[i];     memset(dp, 0, sizeof dp);     for (int i = n - 1; i >= 1; i--) dp[2][i] = dp[2][i + 1] + mp[2][i];     int t1 = 10000000, t2 = 10000000, cnt = 0;     for (int i = 1; i <= n; i++) {       int kl = dp[2][i] + num[i] + cnt;       if (kl < t2) {         if (kl < t1)           t2 = t1, t1 = kl;         else           t2 = kl;       }       cnt += mp[1][i];     }     int ans = t1 + t2;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<string> ss;   string s;   void readInput() { cin >> s; }   void solve() {     for (int i = 0; i <= s.length(); i++) {       for (char c =  a ; c <=  z ; c++) {         string tmp;         tmp += s.substr(0, i) + c + s.substr(i, s.length());         ss.insert(tmp);       }     }     cout << ss.size();   }   int main() {     readInput();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_TAILLE = 100 * 1000 + 3;   long long T[1];   long long paire[MAX_TAILLE], impaire[MAX_TAILLE];   int n, e, a;   long long best;   int main() {     paire[0] = 0;     impaire[0] = 0;     int p = 1, ip = 1;     cin >> n >> e;     T[0] = 0;     for (int i = 1; i <= n; i++) {       cin >> a;       if (i % 2 == 1) {         paire[p] = paire[p - 1] + a - T[0];         p++;       } else {         impaire[ip] = impaire[ip - 1] + a - T[0];         ip++;       }       T[0] = a;     }     if ((n + 1) % 2 == 1) {       paire[p] = paire[p - 1] + e - T[0];       ip--;     } else {       impaire[ip] = impaire[ip - 1] + e - T[0];       p--;     }     best = paire[p];     for (int i = 1; i <= p; i++) {       best = max(best, paire[i] + impaire[ip] - impaire[i - 1] - 1);     }     cout << best;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   const long long maxn = 4005, maxk = 1e5 + 2, mod = 1e9 + 7;   long long a[maxn];   vector<long long> v;   bool mrk[maxn];   int32_t main() {     long long t;     cin >> t;     while (t--) {       long long n, mx = 0, lst = 0;       cin >> n >> mx;       for (long long i = 1; i < 2 * n; i++) {         cin >> a[i];         if (a[i] > mx) {           mx = a[i];           v.push_back(i - lst);           lst = i;         }       }       v.push_back(2 * n - lst);       for (long long i = 1; i <= n; i++) mrk[i] = false;       mrk[0] = true;       for (long long i = 0; i < (long long)(v).size(); i++) {         for (long long j = n - v[i]; j >= 0; j--) mrk[j + v[i]] |= mrk[j];       }       if (mrk[n])         cout <<  YES  <<   n ;       else         cout <<  NO  <<   n ;       v.clear();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int turn = 2 * k + 1;     if (n % turn == 0)       cout << n / turn <<    ;     else       cout << n / turn + 1 <<    ;     double upperbound = (n - 1) % turn + 1;     int MAXN = 0;     upperbound /= 2;     int temp = ceil(upperbound);     for (int i = min(k + 1, temp); i <= n; i += turn) {       cout << i <<    ;       MAXN = i;     }     if (MAXN + k < n) cout << MAXN + 2 * k + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, l, r;     cin >> n >> l >> r;     cout << (n - l) + (int)pow(2, l) - 1 <<              << (n - r) * ((int)pow(2, r - 1)) + ((int)pow(2, r) - 1) << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     char c;     int x = 0;     int b = 1;     do {       c = getchar();       if (c == 45) b = -1;     } while (c > 57 || c < 48);     do x = x * 10 + c - 48, c = getchar();     while (c <= 57 && c >= 48);     x *= b;     return x;   }   int n, m, t;   const int maxn = 300 + 5;   const int logn = 10 + 5;   int f[logn][maxn][maxn];   int g[maxn][maxn], w[maxn][maxn];   int main() {     n = read(), m = read();     t = log2(n);     memset(f, 0xcf, sizeof(f));     memset(w, 0xcf, sizeof(w));     for (int i = 1, x, y, z, l; i <= m; i++) {       x = read(), y = read();       z = read();       l = read();       f[0][x][y] = z, f[0][y][x] = l;     }     for (int i = 1; i <= n; i++) w[i][i] = f[0][i][i] = 0;     for (int s = 1; s <= 10; s++) {       for (int k = 1; k <= n; k++) {         for (int i = 1; i <= n; i++) {           for (int j = 1; j <= n; j++) {             f[s][i][j] = max(f[s][i][j], f[s - 1][i][k] + f[s - 1][k][j]);           }         }       }     }     int ans = 0;     for (int s = 10; s >= 0; s--) {       memset(g, 0xcf, sizeof(g));       for (int k = 1; k <= n; k++) {         for (int i = 1; i <= n; i++) {           for (int j = 1; j <= n; j++) {             g[i][j] = max(g[i][j], w[i][k] + f[s][k][j]);           }         }       }       int sig = 0;       for (int i = 1; i <= n; i++)         if (g[i][i] > 0) sig = 1;       if (sig)         continue;       else {         for (int i = 1; i <= n; i++) {           for (int j = 1; j <= n; j++) {             w[i][j] = g[i][j];           }         }         ans += (1 << s);       }     }     printf( %d n , ans >= n ? 0 : ans + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int a[1001];   map<long long int, int> used;   int ans = 0;   map<pair<long long int, long long int>, bool> us;   void rec(long long int x, long long int y, int kol) {     ans = max(ans, kol);     long long int z = x + y;     if (z > 1000000000 || z < -1000000000) return;     x = y;     y = z;     if (used[z] > 0) {       used[z]--;       rec(x, y, kol + 1);       used[z]++;     }   }   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       used[a[i]]++;     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         if (us[make_pair(a[i], a[j])] || i == j) continue;         us[make_pair(a[i], a[j])] = true;         used[a[i]]--;         used[a[j]]--;         rec(a[i], a[j], 2);         used[a[i]]++;         used[a[j]]++;       }     }     cout << ans << endl;     return 0;   }