malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   long long gi() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) f ^= ch ==  - , ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return f ? x : -x;   }   std::mt19937 rnd(time(NULL));   template <class T>   void cxk(T& a, T b) {     a = a > b ? a : b;   }   template <class T>   void cnk(T& a, T b) {     a = a < b ? a : b;   }   int A[2][3], B[8], C[3];   int main() {     int qwq = gi();     while (qwq--) {       for (int i = 0; i < 2; ++i)         for (int j = 2; ~j; --j) A[i][j] = gi();       for (int j = 7; j; --j) B[j] = gi();       int s = 0;       for (int i = 1; i <= 7; ++i)         if (i != (i & -i)) s += B[i];       for (int i = 0; i < 3; ++i) {         int sum = A[0][i] + A[1][i];         for (int j = 1; j <= 7; ++j)           if (j >> i & 1) sum -= B[j];         if (sum < 0) {           puts( -1 );           goto ed;         }       }       for (int i = 0; i < 3; ++i) C[i] = B[7 ^ (1 << i)];       for (int a = 0, b = s; a <= s; ++a, --b) {         bool flg = 0;         for (int i = 0; i < 3; ++i)           if (std::max(0, a - A[0][i]) + std::max(0, b - A[1][i]) > C[i]) flg = 1;         if (a < std::max(0, a - A[0][0]) + std::max(0, a - A[0][1]) +                     std::max(0, a - A[0][2]))           flg = 1;         if (b < std::max(0, b - A[1][0]) + std::max(0, b - A[1][1]) +                     std::max(0, b - A[1][2]))           flg = 1;         if (flg) continue;         int D[8] = {0};         D[7] = a;         for (int i = 0; i < 3; ++i) {           int p = std::max(0, a - A[0][i]);           D[7 ^ (1 << i)] = p;           D[7] -= p;         }         for (int i = 0; i < 3; ++i) {           int p = std::max(               0, std::min({D[7] - B[7], B[7 ^ (1 << i)] - D[7 ^ (1 << i)],                            C[i] - D[7 ^ (1 << i)] - std::max(0, b - A[1][i])}));           D[7 ^ (1 << i)] += p;           D[7] -= p;         }         for (int i = 0; i < 3; ++i) {           int s = A[0][i];           for (int j = 1; j <= 7; ++j)             if (j >> i & 1) s -= D[j];           D[1 << i] = std::min(s, B[1 << i]);         }         for (int i = 7; i; --i) printf( %d  , D[i]);         puts(  );         for (int i = 1; i <= 7; ++i) assert(D[i] <= B[i]);         for (int i = 0; i < 3; ++i) {           int s1 = 0, s2 = 0;           for (int j = 1; j <= 7; ++j)             if (j >> i & 1) s1 += D[j], s2 += B[j] - D[j];           assert(s1 <= A[0][i] && s2 <= A[1][i]);         }         goto ed;       }       puts( -1 );     ed:;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 5;   const long long mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     long long a[n], b[n];     for (long long i = 0; i < n; i++) cin >> a[i];     for (long long i = 0; i < n; i++) cin >> b[i];     sort(a, a + n, greater<long long>());     sort(b, b + n, greater<long long>());     long long i = 0, j = 0;     long long v1 = 0, v2 = 0;     for (long long c = 0; c < 2 * n; c++) {       long long op1 = (i == n ? 0 : a[i]);       long long op2 = (j == n ? 0 : b[j]);       if (op1 >= op2) {         i++;         if (c % 2 == 0) v1 += op1;       } else {         j++;         if (c & 1) v2 += op2;       }     }     cout << v1 - v2;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const int INF = 1e9;   const long long IINF = 1e18;   const int dx[4] = {1, 0, -1, 0};   const int dy[4] = {0, 1, 0, -1};   const char dir[4] = { D ,  R ,  U ,  L };   template <typename T>   istream &operator>>(istream &is, vector<T> &v) {     for (T &x : v) is >> x;     return is;   }   template <typename T>   ostream &operator<<(ostream &os, const vector<T> &v) {     for (int i = 0; i < v.size(); ++i) {       os << v[i] << (i + 1 == v.size() ?   n  :    );     }     return os;   }   template <typename T, typename U>   ostream &operator<<(ostream &os, const pair<T, U> &p) {     cout <<  (  << p.first <<  ,  << p.second <<  ) ;     return os;   }   template <class T>   inline bool chmin(T &a, T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <class T>   inline bool chmax(T &a, T b) {     if (a < b) {       a = b;       return true;     }     return false;   }   void solve(long long n) {     long long m = n;     vector<int> convert;     while (3 <= m) {       convert.emplace_back(m % 3);       m /= 3;     }     convert.emplace_back(m);     convert.emplace_back(0);     int d = convert.size(), most;     for (most = d - 1; most >= 0; --most) {       if (convert[most] == 2) break;     }     if (most < 0) {       cout << n <<   n ;       return;     }     for (int i = 0; i < most; ++i) convert[i] = 0;     for (int i = most; i < d; ++i) {       if (convert[i] == 2)         convert[i] = 0, convert[i + 1] += 1;       else if (convert[i] == 3)         convert[i] = 0, convert[i + 1] + -1;     }     long long po = 1, ans = 0;     for (int i = 0; i < d; ++i) {       ans += po * convert[i];       po *= 3;     }     cout << ans <<   n ;   }   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int t;     cin >> t;     for (; t--;) {       long long n;       cin >> n;       solve(n);     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000000 + 10;   int cnt[maxn];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < m; ++i) {       int a, b;       scanf( %d%d , &a, &b);       --a, --b;       cnt[a]++;       cnt[b]++;     }     long long tot = 1LL * n * (n - 1) * (n - 2) / 6;     long long bad = 0;     for (int i = 0; i < n; ++i) {       bad += 1LL * cnt[i] * (n - 1 - cnt[i]);     }     cout << tot - bad / 2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b;     getline(cin, a);     getline(cin, b);     long long i = 0, j = 0;     while (a[i] ==  0 ) i++;     while (b[j] ==  0 ) j++;     if (a.size() - i > b.size() - j) {       cout <<  >  << endl;       return 0;     } else if (a.size() - i < b.size() - j) {       cout <<  <  << endl;       return 0;     } else {       while (i < a.size() && j < b.size()) {         if (a[i] > b[j]) {           cout <<  >  << endl;           return 0;         } else if (a[i] < b[j]) {           cout <<  <  << endl;           return 0;         }         i++;         j++;       }     }     cout <<  =  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long N, M, K, ans;   long long a[105][21005];   long long sum[105][21005];   long long tree[21005 * 8];   long long lazy[21005 * 8];   long long dp[21005 * 8];   void updLazy(long long x, long long l, long long r) {     if (!lazy[x]) return;     tree[x] += lazy[x];     lazy[2 * x + 1] += lazy[x];     lazy[2 * x + 2] += lazy[x];     lazy[x] = 0;   }   void upd(long long x, long long l, long long r, long long lq, long long rq,            long long v, bool t) {     if (r < l) return;     updLazy(x, l, r);     if (l > rq or r < lq) return;     if (l >= lq && r <= rq) {       if (t) tree[x] = lazy[x] = 0;       lazy[x] += v;       updLazy(x, l, r);       return;     }     long long mid = (l + r) / 2;     upd(2 * x + 1, l, mid, lq, rq, v, t);     upd(2 * x + 2, mid + 1, r, lq, rq, v, t);     tree[x] = max(tree[2 * x + 1], tree[2 * x + 2]);   }   long long suma2(long long i, long long j) {     return sum[i][j + K - 1] - sum[i][j - 1] + sum[i + 1][j + K - 1] -            sum[i + 1][j - 1];   }   int main() {     cin >> N >> M >> K;     for (long long i = 1; i <= N; i++)       for (long long j = 1; j <= M; j++) {         cin >> a[i][j];         sum[i][j] = sum[i][j - 1] + a[i][j];       }     for (long long i = 1; i <= N; i++)       for (long long j = M + 1; j <= M; j++) sum[i][j] = sum[i][j - 1];     for (long long i = N; i >= 1; i--) {       for (long long j = 1; j + K - 1 <= M; j++) {         if (j <= K)           upd(0, 1, M, j, j, dp[j] - sum[i + 1][K] + sum[i + 1][j - 1], 1);         else           upd(0, 1, M, j, j, dp[j], 1);       }       for (long long j = 1; j + K - 1 <= M; j++) {         dp[j] = suma2(i, j) + tree[0];         ans = max(ans, dp[j]);         upd(0, 1, M, max(1LL, j - K + 1), j, a[i + 1][j], 0);         upd(0, 1, M, j + 1, min(M, j + K), -a[i + 1][j + K], 0);         ans = max(ans, dp[j]);       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   int main() {     int n, co = 1;     std::vector<pair<long long, long long>> v;     cin >> n;     for (int i = 0; i < n; i++) {       long long a, b;       cin >> a >> b;       v.push_back(make_pair(a, b));     }     for (int i = 1; i < n; i++) {       if (v[i].first - v[i].second > v[i - 1].first) {         co++;       } else if (v[i].first + v[i].second < v[i + 1].first) {         v[i].first = v[i].first + v[i].second;         co++;       } else if (i == n - 1) {         co++;       }     }     cout << co;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m;   vector<long long> a(30005);   bool check(long long v) {     long long i, val = 0;     for (i = 0; i < n; i++) {       long long x = a[i];       long long y = (a[i] + v) % m;       if (y >= x) {         if (x > val) val = x;         if (y < val) return false;       } else {         if (val > y) val = max(val, x);       }     }     return true;   }   void solve() {     cin >> n >> m;     a.resize(n);     for (auto &x : a) cin >> x;     long long low = 0, high = m, mid, ans = m;     while (low <= high) {       mid = (low + high) / 2;       long long z = check(mid);       if (z) {         ans = mid;         high = mid - 1;       } else         low = mid + 1;     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200009;   vector<pair<int, int> > grafo[MAXN];   int upth[MAXN], dis[MAXN];   int Build(int u, int p, int upd, int gd) {     upth[u] = upd;     dis[u] = gd;     int ct = 0;     for (int i = 0; i < grafo[u].size(); ++i) {       int v = grafo[u][i].first;       if (v != p) {         int res = Build(v, u, upd + grafo[u][i].second, gd + 1);         ct += res + grafo[u][i].second;       }     }     return ct;   }   int main() {     int N;     scanf( %d n , &N);     for (int i = 1; i < N; ++i) {       int u, v;       scanf( %d%d , &u, &v);       grafo[u].push_back(pair<int, int>(v, 0));       grafo[v].push_back(pair<int, int>(u, 1));     }     int UT = Build(1, 0, 0, 0);     int mint = MAXN;     for (int i = 1; i <= N; ++i) mint = min(mint, UT - (2 * upth[i]) + dis[i]);     printf( %d n , mint);     int cnt = 0;     for (int i = 1; i <= N; ++i)       if ((UT - (2 * upth[i]) + dis[i]) == mint) {         if (cnt++) printf(   );         printf( %d , i);       }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   int A[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};   int main() {     char a, b;     scanf( %c%c , &a, &b);     printf( %d n , A[a -  0 ] * A[b -  0 ]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class A>   void read(vector<A>& v) {     for (auto& x : v) cin >> x;   }   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cout << *x, 0);   template <class c>   char dud(...);   struct debug {     ~debug() { cout << endl; }     template <class c>     typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {       cout << boolalpha << i;       return *this;     }     template <class c>     typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {       return *this << range(begin(i), end(i));     }     template <class c, class b>     debug& operator<<(pair<b, c> d) {       return *this <<  (  << d.first <<  ,   << d.second <<  ) ;     }     template <class c>     debug& operator<<(rge<c> d) {       *this <<  [ ;       for (auto it = d.b; it != d.e; ++it) *this <<  ,   + 2 * (it == d.b) << *it;       return *this <<  ] ;     }   };   const long MOD = 1000000007;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     ;     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int o = 0, z = 0;       for (int _ = 0; _ < n; _++) {         int v;         cin >> v;         if (v == 1)           o++;         else           z++;       }       int times, val;       if (o > z) {         times = o;         val = 1;       } else {         times = z;         val = 0;       }       if (val == 1 && times % 2 && val == 1) times--;       cout << times << endl;       for (int _ = 0; _ < times; _++) cout << val <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   int min(int a, int b) { return (a < b ? a : b); }   int max(int a, int b) { return (a > b ? a : b); }   int main() {     char a[10], b[10];     int x, y;     scanf( %s n%s , a, b);     if (strcmp(a,  sunday ) == 0)       x = 0;     else if (strcmp(a,  monday ) == 0)       x = 1;     else if (strcmp(a,  tuesday ) == 0)       x = 2;     else if (strcmp(a,  wednesday ) == 0)       x = 3;     else if (strcmp(a,  thursday ) == 0)       x = 4;     else if (strcmp(a,  friday ) == 0)       x = 5;     else if (strcmp(a,  saturday ) == 0)       x = 6;     if (strcmp(b,  sunday ) == 0)       y = 0;     else if (strcmp(b,  monday ) == 0)       y = 1;     else if (strcmp(b,  tuesday ) == 0)       y = 2;     else if (strcmp(b,  wednesday ) == 0)       y = 3;     else if (strcmp(b,  thursday ) == 0)       y = 4;     else if (strcmp(b,  friday ) == 0)       y = 5;     else if (strcmp(b,  saturday ) == 0)       y = 6;     if (x == y)       printf( YES );     else if (y == (x + 2) % 7)       printf( YES );     else if (y == (x + 3) % 7)       printf( YES );     else       printf( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, c;   vector<string> v, s1, s2;   bool b1(string &d) {     if (d.size()) {       if (d[0] ==  0  && d.size() == 1) {         return true;       } else if (d[0] ==  0 ) {         return false;       } else {         bool ans = true;         for (int i = 0; i < d.size(); ++i) {           if (!( 0  <= d[i] && d[i] <=  9 )) {             ans = false;             break;           }         }         return ans;       }     } else {       return false;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.precision(11);     cout.setf(ios::fixed);     getline(cin, s);     c =   ;     for (int i = 0; i < s.size(); ++i) {       if (s[i] ==  ,  || s[i] ==  ; ) {         if (b1(c)) {           s1.push_back(c);           c =   ;         } else {           s2.push_back(c);           c =   ;         }       } else {         c.append(1, s[i]);       }     }     if (b1(c)) {       s1.push_back(c);       c =   ;     } else {       s2.push_back(c);       c =   ;     }     if (s1.size()) {       cout <<     << s1[0];       for (int i = 1; i < s1.size(); ++i) {         cout <<  ,  << s1[i];       }       cout <<     << endl;     } else {       cout <<  -  << endl;     }     if (s2.size()) {       cout <<     << s2[0];       for (int i = 1; i < s2.size(); ++i) {         cout <<  ,  << s2[i];       }       cout <<     << endl;     } else {       cout <<  -  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, int> m;   int main() {     int n;     scanf( %d , &n);     long long count = 0;     int flag = 0;     for (int i = 0; i < n; i++) {       long long c;       cin >> c;       if (c > 0) {         m[c] += 1;         if (m[c] == 2) count++;         if (m[c] > 2) flag = 1;       }     }     if (flag)       cout <<  -1  << endl;     else       cout << count << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int vis[100005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int dis[n][n];     vector<int> arr(n);     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) cin >> dis[i][j];     for (int i = 0; i < n; i++) cin >> arr[i];     reverse(arr.begin(), arr.end());     vector<long long> ans;     for (int k = 0; k < n; k++) {       int x = arr[k] - 1;       vis[x] = 1;       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           dis[i][j] = min(dis[i][j], dis[i][x] + dis[x][j]);         }       }       long long sum = 0;       for (int i = 0; i < n; i++) {         if (!vis[i]) continue;         for (int j = 0; j < n; j++)           if (vis[j]) sum += dis[i][j];       }       ans.push_back(sum);     }     reverse(ans.begin(), ans.end());     for (int i = 0; i < ans.size(); i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   int main() {     long long n = 1, k = 1;     int t;     cin >> t;     for (int i = 1; i <= t; i++) {       n %= mod;       k %= mod;       n *= 27;       k *= 7;     }     while (n < k) n += mod;     n -= k;     cout << n % mod << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long int arr[2005];   long long int dp[2005][2005];   long long int n, h;   long long int calc(long long int id, long long int prev) {     if (id == n + 1) {       return !prev;     }     long long int ans = dp[id][prev];     if (ans != -1) {       return ans;     }     long long int val = arr[id] + prev;     ans = 0;     if (val == h) {       ans = calc(id + 1, prev);       if (prev) {         ans = (ans + (prev * calc(id + 1, prev - 1)) % 1000000007) % 1000000007;       }     } else if (val == h - 1) {       ans = calc(id + 1, prev + 1);       ans = (ans + calc(id + 1, prev)) % 1000000007;       ans = (ans + (prev * calc(id + 1, prev)) % 1000000007) % 1000000007;     }     return (dp[id][prev] = ans);   }   int main() {     memset(dp, -1, sizeof(dp));     scanf( %lld , &n);     scanf( %lld , &h);     long long int i;     for (i = 1; i <= n; i++) {       scanf( %lld , &arr[i]);     }     long long int ans = calc(1, 0);     printf( %lld , ans);     ;     printf(  n );     return 0;   }
#include <bits/stdc++.h>   int n, m, H, T, x, y, l, Mark;   int son[200005], ed[200005], next[200005], v[200005], d[200005];   void work(int x, int y) {     ++Mark;     int h = 0, t = 0;     for (int p = son[x]; p; p = next[p])       if (ed[p] != y) v[ed[p]] = Mark, h++;     for (int p = son[y]; p; p = next[p])       if (ed[p] != x)         if (v[ed[p]] != Mark)           t++;         else if (h > H)           v[ed[p]] = 0, h--, t++;     if (h >= H && t >= T) {       printf( YES n%d %d n , x, y);       for (int p = son[x]; p && H; p = next[p])         if (ed[p] != y)           if (v[ed[p]] == Mark) printf( %d%s , ed[p], --H ?     :   n );       for (int p = son[y]; p && T; p = next[p])         if (ed[p] != x)           if (v[ed[p]] != Mark) printf( %d%s , ed[p], --T ?     :   n );       exit(0);     }   }   int main() {     scanf( %d%d%d%d , &n, &m, &H, &T);     for (int i = 1; i <= m; i++)       scanf( %d%d , &x, &y), d[x]++, d[y]++, ed[++l] = y, next[l] = son[x],                                              son[x] = l, ed[++l] = x,                                              next[l] = son[y], son[y] = l;     for (int i = 1; i <= n; i++)       if (d[i] > H)         for (int p = son[i]; p; p = next[p])           if (d[ed[p]] > T) work(i, ed[p]);     printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;      typedef long long LL;      const int maxn = 51;      LL f[maxn][2][maxn * maxn];      int n, mod;      void solve() {       scanf( %d%d , &n, &mod);       int M = n * (n - 1) / 2;          memset(f, 0, sizeof f);       f[0][0][M] = 1 % mod;       for (int i = 0; i < n; i++) {           for (int r = 0; r <= M + M; r++) {               if (f[i][0][r]) {                   for (int k1 = 0; k1 < n - i; k1++)                       for (int k2 = k1; k2 < n - i; k2++) {                           if (k1 == k2)                               (f[i + 1][0][r] += f[i][0][r]) %= mod;                           else                               (f[i + 1][1][r + k1 - k2] += f[i][0][r]) %= mod;                       }               }                  if (f[i][1][r]) {                   for (int k1 = 0; k1 < n - i; k1++)                       for (int k2 = 0; k2 < n - i; k2++)                           (f[i + 1][1][r + k1 - k2] += f[i][1][r]) %= mod;               }           }       }       // for (int r = M; r <= 2 * M; r++) {       //     cout << f[n][1][r] <<    ;       // }       // cout << endl;          LL res = 0;       for (int r = M + 1; r <= M + n * (n - 1) / 2; r++) {           (res += f[n][1][r]) %= mod;       }       printf( %lld n , res);   }   int main() {       int _ = 1;       while (_--) {           solve();       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, xx;     cin >> n >> m >> xx;     map<char, long long int> mp;     vector<char> v[n];     for (long long int i = 0; i < n; i++) {       string s;       cin >> s;       for (auto j : s) v[i].push_back(j);       for (long long int j = 0; j < m; j++) mp[s[j]]++;     }     if (mp[ S ] > 0) {       mp[ S ] = 0;       for (auto i : mp) {         char c = i.first - 32;         if (i.first !=  S ) mp[c]++;       }     }     long long int q;     cin >> q;     string s;     cin >> s;     for (long long int i = 0; i < q; i++) {       if (mp[s[i]] == 0) {         cout <<  -1 ;         return 0;       }     }     vector<pair<long long int, long long int>> shift;     for (long long int i = 0; i < n; i++) {       for (long long int j = 0; j < m; j++) {         if (v[i][j] ==  S ) shift.push_back({i, j});       }     }     vector<long long int> chk[200];     for (long long int i = 0; i < n; i++) {       for (long long int j = 0; j < m; j++) {         for (auto m : shift) {           long long int x = m.first;           long long int y = m.second;           long long int ans = ((x - i) * (x - i)) + ((y - j) * (y - j));           if (ans <= (xx * xx)) chk[v[i][j] - 32].push_back(ans);         }       }     }     long long int c = 0;     for (long long int i = 0; i < q; i++) {       if (s[i] >=  A  && s[i] <=  Z ) {         for (auto j : chk[s[i]]) {           if (j <= (xx * xx)) goto done;         }         c++;       }     done:       1;     }     cout << c;   }
#include <bits/stdc++.h>   using namespace std;   void make_unique(vector<long long> vec) {     sort((vec).begin(), (vec).end());     vec.resize(unique((vec).begin(), (vec).end()) - vec.begin());   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       long long k, n, m, i, j, flag = 0, count = 0, move = 0;       string s;       cin >> n;       long long A[n];       vector<long long> v;       for (i = 0; i < n; i++) cin >> A[i];       long long freq[51] = {0};       for (i = 0; i < n; i++) {         freq[A[i]]++;       }       long long maxf = freq[0];       long long pos = 0;       vector<long long> sum(105, 0);       for (i = 0; i <= n; i++) {         for (j = i; j <= n; j++) {           if (i == j)             sum[i + j] += freq[i] / 2;           else {             sum[i + j] += min(freq[i], freq[j]);           }         }       }       cout << *max_element((sum).begin(), (sum).end()) << endl;     }     return 0;   }