malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int a[100010], dp[100010], rec[100010];   int n;   int main() {     while (~scanf( %d , &n)) {       int maxn = 0;       for (int i = 1; i <= n; i++) {         dp[i] = 1;         scanf( %d , &a[i]);       }       for (int i = 1; i <= n; i++) {         rec[a[i]] = 1;         if (rec[a[i] - 1] > 0) {           dp[a[i]] = dp[a[i] - 1] + 1;         }         maxn = max(maxn, dp[a[i]]);       }       printf( %d n , n - maxn);     }   }
#include <bits/stdc++.h>   using namespace std;   long long zyo[114514], sum[114514], kai[114514];   long long mo = 1000000007;   long long extgcd(long long a, long long b, long long &x, long long &y) {     long long g = a;     x = 1;     y = 0;     if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;     return g;   }   long long invMod(long long a, long long m) {     long long x, y;     if (extgcd(a, m, x, y) == 1) return (x + m) % m;     return 0;   }   long long co(int a, int b) {     if (a < 0 || b < 0 || b > a) return 0;     return ((kai[a] * invMod(kai[b], mo)) % mo * invMod(kai[a - b], mo)) % mo;   }   int main() {     long long out = 0;     int n, k;     string s;     zyo[0] = kai[0] = 1;     sum[0] = 0;     for (int i = 0; i < 100100; i++) {       zyo[i + 1] = (zyo[i] * 10) % mo;       kai[i + 1] = (kai[i] * (i + 1)) % mo;     }     cin >> n >> k;     cin >> s;     reverse(s.begin(), s.end());     for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + (s[i] -  0 );     for (int i = 0; i < n; i++) {       int now = (s[i] -  0 );       out = (out + (zyo[i] * co(n - i - 1, k)) % mo * now) % mo;     }     for (int i = 1; i < n; i++) {       long long now = sum[n] - sum[i];       out = (out + (zyo[i - 1] * co(n - i - 1, k - 1)) % mo * now) % mo;     }     cout << out << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }   bool isPrime(int n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (int i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   struct segment {     int start;     int end;   };   struct monster {     int a;     int b;     int nof_to_kill;     monster(int attack, int health) {       a = attack;       b = health;     }     bool operator<(const monster &new_monster) const {       return (nof_to_kill * a < new_monster.nof_to_kill * new_monster.a);     }   };   void solution() {     int64_t n{};     cin >> n;     cout << -n + 1 <<     << n << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       solution();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e6;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     int h[n];     for (int i = 0; i < n; ++i) {       cin >> h[i];     }     vector<int> v(n, 0);     int maxx = 0;     for (int i = n - 1; i >= 0; i--) {       v[i] = max(0, maxx - h[i] + 1);       maxx = max(maxx, h[i]);     }     for (int i = 0; i < n; i++) {       cout << v[i] <<    ;     }   }
#include <bits/stdc++.h>   int n, m, i, j;   int ord[200000], a0[200000];   bool use[200000];   long long a[200000];   long long k, p, t, q, s;   void qsort(int l, int r) {     int i, j, t, x;     i = l;     j = r;     x = ord[(l + r) / 2];     while (i < j) {       while (a[ord[i]] < a[x]) i++;       while (a[ord[j]] > a[x]) j--;       if (i <= j) {         t = ord[i];         ord[i] = ord[j];         ord[j] = t;         i++;         j--;       }     }     if (l < j) qsort(l, j);     if (i < r) qsort(i, r);   }   int main() {     while (scanf( %d%I64d , &n, &k) != EOF) {       for (i = 1; i <= n; i++) scanf( %I64d , &a[i]);       for (i = 1; i <= n; i++) ord[i] = i;       qsort(1, n);       p = n;       memset(use, 0, sizeof(use));       for (i = 1; i <= n; i++) {         if (k < (a[ord[i]] - a[ord[i - 1]]) * (n - i + 1)) break;         use[ord[i]] = true;         k -= (a[ord[i]] - a[ord[i - 1]]) * (n - i + 1);         s = a[ord[i]];       }       j = n - i + 1;       if (i == n + 1) {         if (k != 0) printf( -1 n );       } else {         for (i = 1; i <= n; i++)           if (!use[i]) {             a[i] -= k / j + s;           }         t = k % j;         for (i = 1; t != 0 && i <= n; i++)           if (!use[i]) {             if (a[i] == 1) {               use[i] = true;               a[i] == 1;             }             t--;           }         j = i;         q = 0;         for (i = j; i <= n; i++)           if (!use[i]) {             q++;             a0[q] = i;           }         for (i = 1; i < j; i++)           if (!use[i]) {             q++;             a0[q] = i;           }         for (i = 1; i < q; i++) printf( %d  , a0[i]);         printf( %d n , a0[q]);       }     }   }
#include <bits/stdc++.h>   int main() {     int n, m;     int a, b;     int min1, min2;     int s1 = 0, s2 = 0, k1 = 0, k2 = 0;     scanf( %d%d , &n, &m);     while (n--) {       scanf( %d , &a);       if (a % 2 == 0)         s1++;       else         s2++;     }     while (m--) {       scanf( %d , &b);       if (b % 2 == 0)         k1++;       else         k2++;     }     if (s1 > k2)       min1 = k2;     else       min1 = s1;     if (k1 > s2)       min2 = s2;     else       min2 = k1;     printf( %d , min1 + min2);   }
#include <bits/stdc++.h>   using namespace std;   long long pow_mod(long long x, long long y) {     long long ret = 1;     while (y) {       if (y & 1) ret = (ret * x) % 1000000007;       x = (x * x) % 1000000007;       y >>= 1;     }     return ret;   }   long long f[2000010];   void init() {     f[0] = 1;     for (int i = 1; i <= 2000005; i++) f[i] = (f[i - 1] * i) % 1000000007;   }   long long inv(long long x) { return pow_mod(x, 1000000007 - 2); }   long long C(long long x, long long y) {     long long ret;     ret = (f[x] * inv(f[y])) % 1000000007;     ret = (ret * inv(f[x - y])) % 1000000007;     return ret;   }   int main() {     init();     int n;     scanf( %d , &n);     long long ans = 0;     for (int i = 0; i <= n; i++) ans = (ans + C(i + n + 1, n)) % 1000000007;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     while (t--) {       long long n, i;       cin >> n;       long long c1 = 0, c2 = 0;       vector<long long> a(n);       for (i = 0; i < n; i++) {         cin >> a[i];         if (a[i] % 2)           c1++;         else           c2++;       }       if (!c2 and c1 == 1)         cout << -1 << endl;       else {         if (c2) {           cout << 1 << endl;           for (i = 0; i < n; i++) {             if (a[i] % 2 == 0) {               cout << i + 1 << endl;               break;             }           }         } else {           cout << 2 << endl;           long long k = 0;           for (i = 0; i < n; i++) {             if (a[i] % 2 == 1) {               cout << i + 1 <<    ;               k++;               if (k == 2) {                 cout << endl;                 break;               }             }           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int casex, n, k;   int num, hed[200010], nex[400010], vt[400010];   long long dp[200010][10], sum[200010], ans;   int read() {     int u = 0;     char c = getchar();     while (c <  0  || c >  9 ) c = getchar();     while (c >=  0  && c <=  9 ) u = (u << 1) + (u << 3) + c -  0 , c = getchar();     return u;   }   void add(int x, int y) {     vt[++num] = y, nex[num] = hed[x], hed[x] = num;     vt[++num] = x, nex[num] = hed[y], hed[y] = num;   }   void dfs1(int u, int fa) {     for (int i = hed[u]; i; i = nex[i]) {       if (vt[i] == fa) continue;       dfs1(vt[i], u);       for (int j = 1; j < k; j++) dp[u][j] += dp[vt[i]][j - 1];       sum[u] += sum[vt[i]] + dp[vt[i]][k - 1];       dp[u][0] += dp[vt[i]][k - 1];     }     dp[u][0]++;   }   void dfs2(int u, int fa) {     int tmp1 = dp[u][k - 1], tmp2 = dp[u][max(0, k - 2)];     for (int j = k - 1; j >= 2; j--) dp[u][j] += dp[fa][j - 1] - dp[u][j - 2];     dp[u][1] += dp[fa][0] - tmp1;     dp[u][0] += dp[fa][k - 1] - tmp2;     sum[u] += sum[fa] - sum[u] - tmp1 + dp[fa][k - 1] - tmp2;     for (int i = hed[u]; i; i = nex[i]) {       if (vt[i] == fa) continue;       dfs2(vt[i], u);     }   }   int main() {     n = read(), k = read();     for (int i = 1; i <= n - 1; i++) {       int x = read(), y = read();       add(x, y);     }     dfs1(1, 0);     for (int i = hed[1]; i; i = nex[i]) dfs2(vt[i], 1);     for (int i = 1; i <= n; i++) {       ans += sum[i];       for (int j = 1; j < k; j++) ans += dp[i][j];     }     printf( %lld , ans / 2);   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   using vi = vector<int>;   using vii = vector<vector<int>>;   const ll LINF = 1LL << 60;   const int INF = 1 << 29;   const int MOD = 1e9 + 7;   int main() {     int n;     cin >> n;     vector<pii> v(n);     for (int i = 0; i < n; i++) {       int x, w;       cin >> x >> w;       v[i] = {x + w, x - w};     }     sort((v).begin(), (v).end());     int ans = 0, cur = -1e9 - 5;     for (int i = 0; i < n; i++) {       if (cur <= v[i].second) {         cur = v[i].first;         ans++;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1100;   int n, m, l[N], u[N], dd, ll;   double d[N][N], p = 1;   vector<pair<int, int> > el;   vector<int> eld;   int main() {     int i, j, x;     cin >> n >> m;     for (i = 1; i <= m; ++i) {       cin >> l[i];       for (j = 1; j <= l[i]; ++j) {         cin >> x;         el.push_back(pair<int, int>(x, i));       }     }     sort(el.begin(), el.end());     dd = el[el.size() - n].first;     for (i = el.size() - 1; el[i].first != dd; --i) {       p = p * (u[el[i].second] + 1) / (l[el[i].second] ? l[el[i].second] : 1);       ++u[el[i].second];       --l[el[i].second];     }     ll = i - el.size() + n + 1;     for (; i >= 0 && el[i].first == dd; --i) eld.push_back(el[i].second);     d[0][0] = p;     for (j = 0; j < eld.size(); ++j)       for (i = 0; i <= j; ++i) {         d[i + 1][j + 1] += d[i][j] * (i + 1.0) / (j + 1.0) * (u[eld[j]] + 1) /                            (l[eld[j]] ? l[eld[j]] : 1);         d[i][j + 1] += d[i][j] * (j - i + 1.0) / (j + 1.0);       }     cout << setprecision(10) << fixed << d[ll][eld.size()];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int rec[40][40][40][40], con[40][40][40][40], r[40][40];   int main() {     int n, m, q, a, c, b, d, i, j, k, l;     string s[50];     scanf( %d %d %d , &n, &m, &q);     for (i = 0; i < n; i++) {       cin >> s[i];     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         r[i][j] = s[i][j] -  0 ;       }     }     rec[0][0][0][0] = r[0][0];     for (j = 1; j < m; j++) {       rec[0][0][0][j] = rec[0][0][0][j - 1] + r[0][j];     }     for (i = 1; i < n; i++) {       rec[0][0][i][0] = rec[0][0][i - 1][0] + r[i][0];       for (j = 1; j < m; j++) {         rec[0][0][i][j] = rec[0][0][i - 1][j] + rec[0][0][i][j - 1] -                           rec[0][0][i - 1][j - 1] + r[i][j];       }     }     for (j = 1; j < m; j++) {       for (k = 0; k < n; k++) {         for (l = j; l < m; l++) {           rec[0][j][k][l] = rec[0][0][k][l] - rec[0][0][k][j - 1];         }       }     }     for (i = 1; i < n; i++) {       for (k = i; k < n; k++) {         for (l = 0; l < m; l++) {           rec[i][0][k][l] = rec[0][0][k][l] - rec[0][0][i - 1][l];         }       }     }     for (i = 1; i < n; i++) {       for (j = 1; j < m; j++) {         for (k = i; k < n; k++) {           for (l = j; l < m; l++) {             rec[i][j][k][l] = rec[0][0][k][l] - rec[0][0][i - 1][l] -                               rec[0][0][k][j - 1] + rec[0][0][i - 1][j - 1];           }         }       }     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         for (k = i; k < n; k++) {           for (l = j; l < m; l++) {             if (rec[i][j][k][l] == 0)               rec[i][j][k][l] = 1;             else               rec[i][j][k][l] = 0;           }         }       }     }     for (a = 0; a < n; a++) {       for (b = 0; b < m; b++) {         con[a][b][a][b] = rec[a][b][a][b];         for (k = a + 1; k < n; k++) {           con[a][b][k][b] = con[a][b][k - 1][b];           for (i = a; i <= k; i++) {             con[a][b][k][b] += rec[i][b][k][b];           }         }         for (l = b + 1; l < m; l++) {           con[a][b][a][l] = con[a][b][a][l - 1];           for (j = b; j <= l; j++) {             con[a][b][a][l] += rec[a][j][a][l];           }         }         for (k = a + 1; k < n; k++) {           for (l = b + 1; l < m; l++) {             con[a][b][k][l] = con[a][b][k - 1][l] + con[a][b][k][l - 1] -                               con[a][b][k - 1][l - 1];             for (i = a; i <= k; i++) {               for (j = b; j <= l; j++) {                 con[a][b][k][l] += rec[i][j][k][l];               }             }           }         }       }     }     for (i = 0; i < q; i++) {       scanf( %d %d %d %d , &a, &b, &c, &d);       printf( %d n , con[a - 1][b - 1][c - 1][d - 1]);     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void out(T x) {     cout << x << endl;     exit(0);   }   const int maxn = 1e6 + 5;   int n, k;   int bsize;   set<int> alive[maxn];   int cnt;   char ask(int i) {     cnt++;     cout <<  ?   << i + 1 << endl;     cout.flush();     char res;     cin >> res;     if (res ==  E ) exit(0);     return res;   }   void reset() {     cout <<  R  << endl;     cout.flush();   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     bsize = max(1, k / 2);     for (int i = 0; i < n; i++) {       alive[i / bsize].insert(i);     }     reset();     set<int> kill;     for (int i = 0; i < n; i++) {       if (ask(i) ==  Y ) {         kill.insert(i);       }     }     for (int x : kill) {       alive[x / bsize].erase(x);     }     for (int i = 0; i < n / bsize; i++) {       for (int j = i + 1; j < n / bsize; j++) {         if (alive[j].empty()) continue;         reset();         for (int x : alive[i]) {           assert(ask(x) ==  N );         }         set<int> kill;         for (int x : alive[j]) {           if (ask(x) ==  Y ) {             kill.insert(x);           }         }         for (int x : kill) {           alive[j].erase(x);         }       }     }     int ans = 0;     for (int i = 0; i < n / bsize; i++) {       ans += alive[i].size();     }     cout <<  !   << ans << endl;     cout.flush();     return 0;   }
#include<bits/stdc++.h>   #define ll long long   #define ri register int   #define lowbit(x) x&(-x)   #define lson rt<<1, l, mid   #define rson rt<<1|1, mid+1, r   using namespace std;   const int p = 1e9+7;   const int maxn = 4e5+10;   int n, m, t, q;   int a[maxn], vis[maxn], go[maxn], two;   int dp[maxn][30];   void divide(int x, int k){    int t = sqrt(x);    for(int i = 2;i <= t;i ++){     if(x%i == 0){      vis[i] += k;      if(vis[i] == 1 && k == -1) two --;      else if(vis[i] >= 2) two ++;      while(x%i == 0) x /= i;     }    }    if(x > 1){     vis[x] += k;     if(vis[x] == 1 && k == -1) two --;     else if(vis[x] >= 2) two ++;    }   }   int main(){    scanf( %d%d ,&n,&q);    for(int i = 1;i <= n;i ++)     scanf( %d ,&a[i]);    int l = 1, r = 0;    while(r < n){     r ++;     divide(a[r], 1);     if(two){      go[l] = r;      while(two){       divide(a[l], -1);       l ++;       go[l] = r;      }     }    }    for(int i = l;i <= n+1;i ++)     go[i] = n+1;    for(int i = 1;i <= n;i ++){     dp[i][0] = go[i];    }    for(int j = 1;j <= 20;j ++)     for(int i = 1;i <= n+1;i ++){      if(dp[dp[i][j-1]][j-1])       dp[i][j] = dp[dp[i][j-1]][j-1];      else dp[i][j] = n+1;     }    for(int i = 1;i <= q;i ++){     int l, r;     ll ans = 0;     scanf( %d%d ,&l,&r);     for(int j = 20;j >= 0;j --){      //cout << l <<     << j <<     << dp[l][j] << endl;      if(dp[l][j] <= r){       l = dp[l][j];       ans += 1ll<<j;      }     }     printf( %lld n ,ans+1);    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int sqr(int v) { return v * v; }   int main() {     int x1, y1, x2, y2, r1, r2;     cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;     if (r1 < r2) swap(x1, x2), swap(y1, y2), swap(r1, r2);     int t1 = sqr(x1 - x2) + sqr(y1 - y2);     long double ans(0);     if (t1 < sqr(r1 - r2))       ans = r1 - r2 - sqrt((long double)t1);     else if (t1 > sqr(r1 + r2))       ans = sqrt((long double)t1) - r1 - r2;     cout << fixed << setprecision(20) << ans / 2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   int c[80][80], m;   struct tree {     int n, ans[80], f[80][5000], g[80][5000];     int root, sum, siz[5000], w[5000], a[5000], tot;     bool vis[5000];     vector<int> v[5000];     inline void getrt(int x, int fa) {       siz[x] = 1;       w[x] = 0;       for (int i = 0; i < v[x].size(); i++)         if (v[x][i] != fa && !vis[v[x][i]]) {           getrt(v[x][i], x);           siz[x] += siz[v[x][i]];           w[x] = max(w[x], siz[v[x][i]]);         }       w[x] = max(w[x], sum - siz[x]);       if (!root || w[x] < w[root]) root = x;     }     inline void dfs(int x, int fa) {       a[++tot] = x;       siz[x] = 1;       for (int i = 0; i < v[x].size(); i++)         if (v[x][i] != fa && !vis[v[x][i]]) {           dfs(v[x][i], x);           siz[x] += siz[v[x][i]];         }     }     inline void work(int x) {       tot = 0;       dfs(x, 0);       int i, j, k;       memset(f, 0, sizeof(f));       memset(g, 0, sizeof(g));       f[0][x] = g[0][x] = 1;       for (i = 1; i <= m; i++)         for (j = 1; j <= tot; j++) {           for (k = 0; k < v[a[j]].size(); k++) {             if (vis[v[a[j]][k]]) continue;             if (a[j] != x) f[i][a[j]] = (f[i][a[j]] + f[i - 1][v[a[j]][k]]) % mod;             g[i][a[j]] = (g[i][a[j]] + g[i - 1][v[a[j]][k]]) % mod;           }         }       for (i = 1; i <= tot; i++) {         if (a[i] == x) {           for (j = 0; j <= m; j++) ans[j] = (ans[j] + g[j][a[i]]) % mod;         } else {           for (j = 0; j <= m; j++)             for (k = 0; k + j <= m; k++)               ans[k + j] =                   (ans[k + j] + (long long)f[j][a[i]] * g[k][a[i]] % mod) % mod;         }       }       vis[x] = 1;       for (i = 0; i < v[x].size(); i++)         if (!vis[v[x][i]]) {           root = 0;           sum = siz[v[x][i]];           getrt(v[x][i], x);           work(root);         }     }     inline void solve() {       sum = n;       root = 0;       memset(vis, 0, sizeof(vis));       memset(ans, 0, sizeof(ans));       getrt(1, 0);       work(root);     }   };   tree t1, t2;   int main() {     int i, j, k;     scanf( %d%d%d , &t1.n, &t2.n, &m);     c[0][0] = 1;     for (i = 1; i <= m; i++) c[i][i] = c[i][0] = 1;     for (i = 1; i <= m; i++)       for (j = 1; j < i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;     for (i = 0; i <= t1.n; i++) t1.v[i].clear();     for (i = 0; i <= t2.n; i++) t2.v[i].clear();     for (i = 1; i < t1.n; i++) {       int x, y;       scanf( %d%d , &x, &y);       t1.v[x].push_back(y);       t1.v[y].push_back(x);     }     for (i = 1; i < t2.n; i++) {       int x, y;       scanf( %d%d , &x, &y);       t2.v[x].push_back(y);       t2.v[y].push_back(x);     }     t1.solve(), t2.solve();     int Ans = 0;     for (i = 0; i <= m; i++)       Ans = (Ans + (long long)t1.ans[i] * t2.ans[m - i] % mod * c[m][i]) % mod;     cout << Ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int N = 1e6 + 10;   int n;   long long cnt[4][20][20];   int dp[N][20][3];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     int lg2 = log2(n);     dp[1][lg2][0] = 1;     if (pow(2, lg2 - 1) * 3 <= n) dp[1][lg2 - 1][1] = 1;     for (int i = 0; i <= lg2; ++i)       for (int j = 0; j <= 1; ++j) {         int value = pow(2, i) * pow(3, j);         int upper = n / value;         cnt[0][i][j] = upper;         for (int k = 1; k <= upper; ++k) {           cnt[1][i][j] += (k % 2 != 0);           cnt[2][i][j] += (k % 3 != 0);         }       }     for (int i = 1; i <= n; ++i)       for (int l2 = lg2; l2 >= 0; --l2)         for (int l3 = 1; l3 >= 0; --l3)           if (dp[i][l2][l3]) {             if (cnt[0][l2][l3] > i)               dp[i + 1][l2][l3] =                   (dp[i + 1][l2][l3] +                    (long long)dp[i][l2][l3] * (cnt[0][l2][l3] - i) % MOD) %                   MOD;             if (l2 > 0)               dp[i + 1][l2 - 1][l3] =                   (dp[i + 1][l2 - 1][l3] +                    (long long)dp[i][l2][l3] * cnt[1][l2 - 1][l3] % MOD) %                   MOD;             if (l3 > 0)               dp[i + 1][l2][l3 - 1] =                   (dp[i + 1][l2][l3 - 1] +                    (long long)dp[i][l2][l3] * cnt[2][l2][l3 - 1] % MOD) %                   MOD;           }     cout << dp[n][0][0];   }
#include <bits/stdc++.h>   const int N = 400 + 10, MOD = 1000000007;   inline void add(int &lhs, long long rhs) { lhs = (lhs + rhs) % MOD; }   int n, f[N][N];   int main() {     scanf( %d , &n);     f[1][0] = f[1][1] = 1;     for (int i = 2; i <= n; ++i) {       for (int x = 0; x <= n; ++x) {         for (int y = 0; x + y <= n; ++y) {           int cur = (long long)f[i - 1][x] * f[i - 1][y] % MOD;           if (!cur) continue;           add(f[i][x + y], cur);           add(f[i][x + y + 1], cur);           if (x) add(f[i][x + y], 2LL * x * cur);           if (y) add(f[i][x + y], 2LL * y * cur);           if (x || y) add(f[i][x + y - 1], (x + y) * (x + y - 1LL) * cur);         }       }     }     printf( %d n , f[n][1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(int base, long long p) {     long long res = 1;     while (p) {       if (p & 1) {         res *= base;         --p;       }       base *= base;       p /= 2;     }     return res;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<int> vec;       for (int i = 0; i < (int)(n); ++i) {         int x;         cin >> x;         vec.push_back(x);       }       sort((vec).begin(), (vec).end());       int sz = unique((vec).begin(), (vec).end()) - vec.begin();       if (sz == n)         cout <<  No  <<   n ;       else         cout <<  Yes  <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 5000;   long long n, a, b, c, d;   pair<long long, long long> p[MAX];   bool cmp(pair<int, int> x, pair<int, int> y) {     if (x.first > y.first) return 1;     if (x.first == y.first) return x.second < y.second;     return 0;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a >> b >> c >> d;       long long sum = a + b + c + d;       p[i].first = sum;       p[i].second = i + 1;     }     sort(p, p + n, cmp);     for (int i = 0; i < n; i++)       if (p[i].second == 1) {         cout << i + 1 << endl;         break;       }     return 0;   }