malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   const int N = 2e5 + 5;   vector<pair<long long, long long> > v;   long long n, m, k;   void solve() {     sort(v.rbegin(), v.rend());     long long sum = 0;     vector<long long> index;     for (long long i = 0; i < m * k; i++) {       sum += v[i].first;       index.push_back(v[i].second);     }     sort(index.begin(), index.end());     cout << sum <<   n ;     for (int i = 0; i < k - 1; i++) cout << index[(i + 1) * m - 1] <<    ;   }   int main() {     fast();     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       long long t;       cin >> t;       v.push_back(make_pair(t, i + 1));     }     solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k, a, b, v, ans;     while (scanf( %d%d%d%d , &k, &a, &b, &v) != EOF) {       ans = 0;       while (a > 0) {         if (b >= k - 1) {           b -= (k - 1);           a -= v * k;           ans++;         } else {           b = b + 1;           a -= v * b;           ans++;           b = 0;         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> graph[80005];   bool vis[100005];   long long int size[100005];   long long int arr[100005];   long long int ans2;   long long int ans;   int dfs1(int node) {     vis[node] = true;     int ret = 1;     for (int i = 0; i < graph[node].size(); i++) {       if (vis[graph[node][i]]) continue;       ret += dfs1(graph[node][i]);     }     return (size[node] = ret);   }   void dfs2(int node, long long int cum) {     vis[node] = true;     long long int rem = n - size[node];     int i;     long long int sum = 0, sqsum = 0, temp;     for (i = 0; i < graph[node].size(); i++) {       if (vis[graph[node][i]]) continue;       temp = size[graph[node][i]];       sum += temp;       sqsum += temp * temp;     }     long long int paths = (sum * sum - sqsum) / 2 + sum;     ans += (rem * (rem - 1) / 2) * paths;     ans2 += cum * paths;     for (i = 0; i < graph[node].size(); i++) {       if (vis[graph[node][i]]) continue;       temp = size[graph[node][i]];       dfs2(graph[node][i], cum + (-(sum - temp) + (sqsum - temp * temp)) / 2);     }   }   int main() {     int i, a, b;     scanf( %d , &n);     for (i = 0; i < n - 1; i++) {       scanf( %d , &a);       scanf( %d , &b);       graph[a].push_back(b);       graph[b].push_back(a);     }     memset(vis, 0, sizeof(vis));     dfs1(1);     ans = 0;     ans2 = 0;     memset(vis, 0, sizeof(vis));     dfs2(1, 0);     ans = 2 * ans - ans2;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   struct custom_hash {     static uint64_t splitmix64(uint64_t x) {       x += 0x9e3779b97f4a7c15;       x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;       x = (x ^ (x >> 27)) * 0x94d049bb133111eb;       return x ^ (x >> 31);     }     size_t operator()(uint64_t x) const {       static const uint64_t FIXED_RANDOM =           chrono::steady_clock::now().time_since_epoch().count();       return splitmix64(x + FIXED_RANDOM);     }   };   signed main(void) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long arr[n];       long long sum = 0;       for (long long i = 0; i < n; i++) {         cin >> arr[i];         sum += arr[i];       }       sum = 2 * sum;       if (sum % n) {         cout << 0 <<   n ;         continue;       }       sum /= n;       long long ans = 0;       unordered_map<long long, long long, custom_hash> mp1;       for (long long i = 0; i < n; i++) {         ans += mp1[sum - arr[i]];         mp1[arr[i]]++;       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   char ff[1005][1005];   int main() {     int t;     scanf( %d , &t);     for (int i = 0; i < t; i++) {       int zz[1005];       int n, m, x, y;       int ww = 0;       int w = 0;       scanf( %d%d%d%d , &n, &m, &x, &y);       for (int j = 1; j <= n; j++) {         char f[1005];         scanf( %s , f);         memset(zz, 0, sizeof(zz));         for (int z = 0; z < strlen(f); z++) {           ff[j][z + 1] = f[z];           if (ff[j][z + 1] == ff[j][z] && ff[j][z] ==  .  && zz[z + 1] == 0 &&               zz[z] == 0) {             ww++;             zz[z + 1] = 1;             zz[z] = 1;           }           if (ff[j][z + 1] ==  . ) w++;         }       }       if (y >= 2 * x) {         printf( %d n , x * w);       } else         printf( %d n , ww * y + x * (w - ww * 2));     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000;   const int MAX = 100000 + 100;   const int inf = 999999999;   const int p1 = 104393321, p2 = 104393329;   int n, m;   int par[MAX], sizeofcom[MAX], size[MAX], a[MAX], b[MAX], d[MAX];   bool lucky(int x) {     while (x > 0) {       if (x % 10 == 7 || x % 10 == 4)         x /= 10;       else         return false;     }     return true;   }   int find(int k) {     if (par[k] == k)       return k;     else       par[k] = find(par[k]);     return par[k];   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> m;     for (int i = (0); i < int(n); ++i) par[i] = i;     int x, y;     for (int i = (0); i < int(m); ++i) {       cin >> x >> y;       x--;       y--;       par[find(x)] = find(y);     }     for (int i = (0); i < int(n); ++i) sizeofcom[find(i)]++;     for (int i = (0); i < int(n + 1); ++i) size[sizeofcom[i]]++;     for (int i = (1); i < int(n + 1); ++i)       if (lucky(i) && size[i]) {         cout << 0 << endl;         return 0;       }     int sz = 0;     for (int i = (1); i < int(n + 1); ++i) {       int tmp = 1;       while (tmp <= size[i]) {         a[sz] = tmp * i;         b[sz++] = tmp;         size[i] -= tmp;         tmp *= 2;       }       if (size[i]) {         a[sz] = size[i] * i;         b[sz++] = size[i];       }     }     int ans = inf;     for (int i = (1); i < int(n + 1); ++i) d[i] = inf;     d[a[0]] = 1;     for (int j = (1); j < int(sz); ++j) {       for (int i = (n); i > int(0); --i) {         if (a[j] <= i) d[i] = min(d[i], d[i - a[j]] + b[j]);         if (lucky(i) && d[i] != inf) ans = min(ans, d[i]);       }     }     if (ans == inf)       cout << -1 << endl;     else       cout << ans - 1 << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   int main() {     string s1, s2, s;     int n, m;     scanf( %d%d , &n, &m);     map<string, string> mp;     for (int i = 0; i < m; ++i) {       cin >> s1 >> s2;       if (s2.size() >= s1.size())         mp[s1] = s1;       else         mp[s1] = s2;     }     for (int i = 0; i < n; ++i) {       cin >> s;       cout << mp[s] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int INF = 2e9;   const long long int LONGINF = 4e18;   long long int inv[200200], fct[200200], invfct[200200];   long long int c[2222];   long long int C(long long int n, long long int k) {     return fct[n] * invfct[n - k] % mod * invfct[k] % mod;   }   void solve(int n) {     int m, g;     long long int c, ans = 0;     scanf( %d%d , &m, &g);     inv[1] = 1;     fct[0] = 1;     fct[1] = 1;     invfct[0] = 1;     invfct[1] = 1;     for (int i = (2); i < (200200); i++) {       inv[i] = -((long long int)mod / i * inv[mod % i] % mod) + mod;       fct[i] = fct[i - 1] * i % mod;       invfct[i] = invfct[i - 1] * inv[i] % mod;     }     if (m == 0) {       if (n % 2 == 1 - g) {         printf( 1 );       } else {         printf( 0 );       }       return;     }     c = C(n + m - 1, n);     for (int i = 0; i < (n + 1); i++) {       if (m == 1 && i == n) {         if ((n + 1) % 2 == g) {           ans++;           ans %= mod;         }         continue;       }       if (i % 2 == g) {         ans += c;         ans %= mod;       }       c = c * inv[n + m - i - 1] % mod * (n - i) % mod;       ;     }     printf( %I64d , ans);   }   int main() {   #pragma comment(linker,  /STACK:268435456 )     int n;     long long int a;     char c[200200];     string s;     while (scanf( %d , &n) == 1) solve(n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x[110], s[110];   int main() {     int n, m;     cin >> n >> m;     for (int i = (1); i < (n + 1); i++) cin >> x[i];     for (int i = (1); i < (n + 1); i++) s[i] = s[i - 1] + x[i];     int v = 0;     while (m--) {       int l, r;       cin >> l >> r;       if (s[r] - s[l - 1] > 0) v += s[r] - s[l - 1];     }     cout << v <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9;   vector<vector<int>> g;   vector<int> vis, cap;   void dfs(int s) {     vis[s] = 1;     cap[s] = 1;     for (int i : g[s]) {       if (vis[i] == 0) {         dfs(i);       }     }   }   int32_t main() {     {       ios_base::sync_with_stdio(false);       cin.tie(NULL);     }     int n, m;     cin >> n >> m;     vector<vector<int>> a(n);     g.resize(m + 1);     vis.assign(m + 1, 0);     cap.assign(m + 1, 0);     for (int i = 0; i < n; i++) {       int k;       cin >> k;       a[i].resize(k);       for (int j = 0; j < k; j++) {         cin >> a[i][j];       }     }     for (int i = 1; i < n; i++) {       int k0 = a[i - 1].size(), k1 = a[i].size();       int j = 0, f = 0;       while (j < k0 and j < k1) {         if (a[i - 1][j] == a[i][j]) {           j++;           continue;         }         f = 1;         if (a[i - 1][j] < a[i][j]) {           g[a[i][j]].push_back(a[i - 1][j]);         } else {           cap[a[i - 1][j]] = 1;         }         break;       }       if (f == 0) {         if (a[i].size() < a[i - 1].size()) {           cout <<  No ;           return 0;         }       }     }     for (int i = 1; i <= m; i++) {       if (vis[i] == 0 and cap[i] == 1) {         dfs(i);       }     }     for (int i = 1; i < n; i++) {       int k0 = a[i - 1].size(), k1 = a[i].size();       int j = 0;       while (j < k0 and j < k1) {         if (a[i - 1][j] == a[i][j]) {           j++;           continue;         }         if (a[i - 1][j] < a[i][j]) {           if (cap[a[i][j]] == 1 and cap[a[i - 1][j]] != 1) {             cout <<  No ;             return 0;           }         } else {           if (cap[a[i][j]] == 1) {             cout <<  No ;             return 0;           }         }         break;       }     }     {       cout <<  Yes n ;       vector<int> ans;       for (int i = 1; i <= m; i++) {         if (cap[i] == 1) {           ans.push_back(i);         }       }       cout << ans.size() <<   n ;       for (int i : ans) {         cout << i <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void read(T& num) {     char CH;     bool F = false;     for (CH = getchar(); CH <  0  || CH >  9 ; F = CH ==  - , CH = getchar())       ;     for (num = 0; CH >=  0  && CH <=  9 ;          num = num * 10 + CH -  0 , CH = getchar())       ;     F && (num = -num);   }   int stk[70], tp;   template <class T>   inline void print(T p) {     if (!p) {       puts( 0 );       return;     }     while (p) stk[++tp] = p % 10, p /= 10;     while (tp) putchar(stk[tp--] +  0 );     putchar(  n );   }   const long long mod = 1e9 + 7;   const double PI = acos(-1.0);   const int inf = 1e9;   const int N = 1e5 + 10;   const int maxn = 1e3 + 20;   const double eps = 1e-12;   int check(int x) {     int l = 1, r = 1000005;     if (x == 0) return 0;     while (l <= r) {       int mid = (l + r) >> 1;       if ((long long)mid * (mid - 1) < (long long)2 * x)         l = mid + 1;       else         r = mid - 1;     }     return l;   }   int main() {     int a, b, c, d;     read(a);     read(b);     read(c);     read(d);     int x = check(a), y = check(d);     if (x == 0 && (b || c)) x = 1;     if (y == 0 && (b || c)) y = 1;     if ((long long)x * (x - 1) != (long long)2 * a ||         (long long)y * (y - 1) != (long long)2 * d ||         (long long)x * y != (long long)b + c)       cout <<  Impossible n ;     else {       if (x == 0 && y == 0)         printf( 0 );       else if (x == 0) {         for (int i = 1; i <= y; i++) printf( 1 );       } else if (y == 0) {         for (int i = 1; i <= x; i++) printf( 0 );       } else {         int t = b / y, f = y - b % y;         for (int i = 1; i <= t; i++) printf( 0 ), x--;         for (int i = 1; i <= f; i++) printf( 1 ), y--;         if (x > 0) {           printf( 0 );           x--;         }         for (int i = 1; i <= y; i++) printf( 1 );         for (int i = 1; i <= x; i++) printf( 0 );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   const int P = 1e9 + 7;   template <typename T>   void chkmax(T &x, T y) {     x = max(x, y);   }   template <typename T>   void chkmin(T &x, T y) {     x = min(x, y);   }   template <typename T>   void read(T &x) {     x = 0;     int f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -f;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     x *= f;   }   template <typename T>   void write(T x) {     if (x < 0) x = -x, putchar( - );     if (x > 9) write(x / 10);     putchar(x % 10 +  0 );   }   template <typename T>   void writeln(T x) {     write(x);     puts(  );   }   int n, bit[MAXN], cnt[MAXN], a[MAXN];   int main() {     read(n), bit[0] = 1;     for (int i = 1; i <= n; i++) {       bit[i] = bit[i - 1] * 2 % P;       read(a[i]);       if (a[i] != -1) cnt[a[i]]++;     }     int ans = bit[n - 1] - 1;     for (int i = 1; i <= n; i++)       if (a[i] == -1) ans = (ans - (bit[cnt[i]] - 1)) % P;     writeln((ans + P) % P);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int rain(int n, int *T, int i) {     int r = 1;     int d = i + 1, g = i - 1, ex = i;     while ((g >= 0) && (T[g] <= T[i])) {       r++;       i = g;       g--;     }     i = ex;     while ((d < n) && (T[d] <= T[i])) {       r++;       i = d;       d++;     }     return r;   }   int max(int n, int *T) {     int x;     x = rain(n, T, 0);     for (int i = 1; i < n; i++) {       if (rain(n, T, i) > x) x = rain(n, T, i);     }     return x;   }   int main() {     int *T;     int n;     cin >> n;     T = new int[n];     for (int i = 0; i < n; i++) cin >> T[i];     cout << max(n, T);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[131100];   int cal(int l, int r, char t) {     int cnt = 0;     for (int i = l; i <= r; i++) {       if (s[i] != t) cnt++;     }     return cnt;   }   int dfs(int l, int r, char t) {     if (l == r) return cal(l, r, t);     int ret = 1e9;     int mid = (l + r) >> 1;     ret = min(ret, dfs(l, mid, t + 1) + cal(mid + 1, r, t));     ret = min(ret, dfs(mid + 1, r, t + 1) + cal(l, mid, t));     return ret;   }   int main() {     int _;     scanf( %d , &_);     while (_--) {       int n;       scanf( %d , &n);       scanf( %s , s);       char temp =  a ;       printf( %d n , dfs(0, n - 1, temp));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mo = 1e9 + 7;   char s[2010], ss[2010];   long long dp[2010][2010], a[2010];   long long m, d, jo;   int len;   long long dfs(int pos, long long sum, bool limit) {     if (pos == len) return sum == 0;     if (!limit && dp[pos][sum] != -1) return dp[pos][sum];     int up = limit ? a[pos] : 9;     long long tmp = 0;     for (int i = 0; i <= up; i++) {       if (pos & 1) {         if (i == d)           tmp =               (tmp + dfs(pos + 1, (sum * 10 + i) % m, limit && i == a[pos])) % mo;       } else if (i != d)         tmp = (tmp + dfs(pos + 1, (sum * 10 + i) % m, limit && i == a[pos])) % mo;     }     if (!limit) dp[pos][sum] = tmp;     return tmp;   }   int solve(char *s) {     int pos = strlen(s) - 1;     len = 0;     while (len <= pos) {       a[len] = s[len] -  0 ;       len++;     }     long long as = dfs(0, 0, true);     return as;   }   int main() {     int le, ri;     while (scanf( %lld%lld , &m, &d) != EOF) {       memset(dp, -1, sizeof(dp));       scanf( %s%s , s, ss);       int l = strlen(s);       long long spc = 1, sm = 0;       for (int i = 0; i < l; i++) {         if ((i % 2 == 0) && ((s[i] & 15) == d)) {           spc = 0;           break;         } else if ((i & 1) && ((s[i] & 15) != d)) {           spc = 0;           break;         }         sm = (sm * 10 + (s[i] & 15)) % m;       }       if (spc) spc = (sm == 0);       printf( %lld n , (solve(ss) - solve(s) + spc + mo) % mo);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N;   long long M;   int A[200002], B[200002];   map<int, int> MP;   vector<pair<long long, long long> > ST;   long long getover(pair<long long, long long> p, int i2) {     if (p.second >= ST[i2].second) return 0;     return (ST[i2].second - p.second) / (p.first - ST[i2].first) +            ((ST[i2].second - p.second) % (p.first - ST[i2].first) != 0);   }   long long getover(int i1, int i2) {     if (ST[i1].second >= ST[i2].second) return 0;     return (ST[i2].second - ST[i1].second) / (ST[i1].first - ST[i2].first) +            ((ST[i2].second - ST[i1].second) % (ST[i1].first - ST[i2].first) != 0);   }   int main() {     cin.sync_with_stdio(false);     cin >> N >> M;     int bestinit = 0;     for (int i = 1; i <= N; ++i) {       cin >> A[i] >> B[i];       if (B[i] == 0) bestinit = max(bestinit, A[i]);       if (MP.find(A[i]) == MP.end()) MP[A[i]] = 0x3f3f3f3f;       MP[A[i]] = min(MP[A[i]], B[i]);     }     ST.push_back(make_pair(bestinit, 0));     for (map<int, int>::iterator it = MP.begin(); it != MP.end(); ++it) {       if (it->first <= bestinit) continue;       int step = (1 << 17), now = 0;       for (; step; step >>= 1)         if (now + step < int(ST.size()) &&             1LL * ST[now + step - 1].first *                         (getover(now + step, now + step - 1) - 1) +                     ST[now + step - 1].second <                 it->second)           now += step;       step = (1 << 30);       int pos = 0;       for (; step; step >>= 1)         if (ST[now].first * (pos + step - 1) + ST[now].second < it->second)           pos += step;       int rem = ST[now].first * pos + ST[now].second - it->second;       pair<long long, long long> pnow =           make_pair(it->first, rem - 1LL * it->first * pos);       while (ST.size() >= 2 && getover(pnow, ST.size() - 1) <=                                    getover(ST.size() - 1, ST.size() - 2))         ST.pop_back();       ST.push_back(pnow);     }     int step = (1 << 17), now = 0;     for (; step; step >>= 1)       if (now + step < int(ST.size()) &&           1LL * ST[now + step - 1].first *                       (getover(now + step, now + step - 1) - 1) +                   ST[now + step - 1].second <               M)         now += step;     long long times = 100000000 + M / ST.back().first;     long long astep = 1;     while (astep <= times) astep *= 2;     long long pos = 0;     for (; astep; astep >>= 1)       if (ST[now].first * (pos + astep - 1) + ST[now].second < M) pos += astep;     cout << pos <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int b[200010];   int main() {     long long n;     cin >> n;     for (int i = 0; i < n; i++) scanf( %d , &b[i]);     sort(b, b + n);     int m = b[n - 1] - b[0];     int m1 = b[n - 1], m2 = b[0];     long long c1 = 0, c2 = 0;     for (int i = 0; i < n; i++) {       if (b[i] == m1) c1++;       if (b[i] == m2) c2++;     }     printf( %d  , m);     if (m1 == m2)       cout << n * (n - 1) / 2 << endl;     else       cout << c1 * c2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long int binomialCoeff(long long int n, long long int k) {     long long int C[n + 1][k + 1];     long long int i, j;     for (i = 0; i <= n; i++) {       for (j = 0; j <= min(i, k); j++) {         if (j == 0 || j == i)           C[i][j] = 1;         else           C[i][j] = ((C[i - 1][j - 1]) % 998244353 + (C[i - 1][j]) % 998244353) %                     998244353;       }     }     return C[n][k];   }   long long int digsum(long long int a) {     long long int sum = 0;     while (a > 0) {       sum += a % 10;       a = a / 10;     }     return sum;   }   long long int power(long long int x, long long int y, long long int p) {     long long int res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   int fact(int a) {     if (a == 1)       return a;     else       return a * fact(a - 1);   }   int max3(int a, int b, int c) { return max(a, max(b, c)); }   int main() {     int q;     cin >> q;     while (q--) {       int n;       cin >> n;       int temp;       int each = 0;       for (long long int i = 1; i <= n; i++) {         cin >> temp;         each += temp;       }       cout << (int)(ceil((double)(each) / (double)(n))) << endl;     }     return 0;   }
#include<bits/stdc++.h>   #define ll long long   #define ld long double   #define pb push_back   #define x first   #define y second   #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);   using namespace std;      //modulo op      const ll mod = 1e9 + 7;      ll add(ll a, ll b) {    return (a + b) % mod;   }      ll sub(ll a, ll b) {    return ((a - b) % mod + mod) % mod;   }      ll mul(ll a, ll b) {    return (a * b) % mod;   }      ll normalize(ll a) {    return (a % mod + mod) % mod;   }   //end of modulo op   ll power(ll a, ll b) {    if (b == 0)     return 1;    ll val = power(a, b / 2);    val = mul(val, val);    if (b & 1)     val = mul(val, a);    return val;   }      const int maxn = 2e5 + 7;   ll fact[maxn], ifact[maxn];      void precalc() {    fact[0] = 1;    ifact[0] = 1;    for (int i = 1; i < maxn; i++) {     fact[i] = mul(i, fact[i - 1]);     ifact[i] = power(fact[i], mod - 2);    }   }      ll ncr(ll n, ll r) {    return mul(fact[n], mul(ifact[n - r], ifact[r]));   }         void solve() {    ll n, l, r;    cin >> n >> l >> r;    ll double_op_limit = min(1 - l, r - n);    ll ans = mul(add(ncr(n, n / 2), n & 1 == 1 ? ncr(n, n / 2 + 1) : 0), double_op_limit);    // cout << double_op_limit <<     << ans << endl;    for (ll i = double_op_limit + 1; i <= double_op_limit + n; i++) {     ll left_fixed = max(l + i - 1, 0LL);     ll right_fixed = n - min(n, r - i);     // cout << i <<     << left_fixed <<     << right_fixed << endl;     if (left_fixed > (n + 1) / 2 || right_fixed > (n + 1) / 2)      break;     ll rem = n - left_fixed - right_fixed;     if (rem < 0)      break;     if (left_fixed == (n + 1) / 2) {      ans = add(ans, 1);      break;     }     ans = add(ans, ncr(rem, n / 2 - left_fixed));     if (n & 1)      ans = add(ans, ncr(rem, n / 2 + 1 - left_fixed));     // cout << ans << endl;    }    cout << ans;   }      int main()   {    fastread;    precalc();    int t;    cin >> t;    while (t--) {     solve();     cout <<   n ;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   __attribute__((constructor)) void Init() {     ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;   }   constexpr int N = 5e3;   char A[N + 2], B[N + 2];   int16_t dp[2][N + 1];   int main() {     int n, m, t = 0, ans = 0;     cin >> n >> m >> &A[1] >> &B[1];     for (int i = 1; i <= n; ++i, t = 1 - t) {       for (int j = 1; j <= m; ++j) {         int s = dp[1 - t][j - 1] + 4 * (A[i] == B[j]) - 2;         dp[t][j] = max(0, max(s, max(dp[t][j - 1], dp[1 - t][j]) - 1));         ;         ans = max<int>(ans, dp[t][j]);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     cin.tie(nullptr)->sync_with_stdio(false);     long long _;     for (cin >> _; _--;) {       long long n, m, k;       cin >> n >> m >> k;       long long mn = (n % 2 == 1 ? m / 2 : 0);       long long mx = n * m / 2 - (m % 2 == 1 ? n / 2 : 0);       if (mn <= k and k <= mx and (k - mn) % 2 == 0)         cout <<  YES n ;       else         cout <<  NO n ;     }   }