malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int dcmp(double a, double b) {     return fabs(a - b) < (1e-9) ? 0 : a < b ? -1 : +1;   }   int main() {     int tc;     scanf( %d , &tc);     while (tc--) {       int n;       scanf( %d , &n);       printf( %d n , n / 2);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 4e18;   long long ver[305][305], hor[305][305], ver2[305][305], hor2[305][305];   int con[305][305];   pair<pair<int, int>, pair<int, int> > ans;   long long dif = inf, cur, a, b;   int main(void) {     memset(ver, 0, sizeof(ver));     memset(hor, 0, sizeof(hor));     memset(ver2, 0, sizeof(ver2));     memset(hor2, 0, sizeof(hor2));     int n, m, t, i, j, k, l, r, mid, it;     int eq, asc, des;     scanf( %d %d %d , &n, &m, &t);     scanf( %d %d %d , &eq, &asc, &des);     for ((i) = (1); (i) <= (n); ++(i)) {       for ((j) = (1); (j) <= (m); ++(j)) {         scanf( %d , &con[i][j]);         if (j > 1) {           hor[i][j] = hor[i][j - 1];           hor2[i][j] = hor2[i][j - 1];           if (con[i][j] == con[i][j - 1]) {             hor[i][j] += eq;             hor2[i][j] += eq;           } else if (con[i][j - 1] < con[i][j]) {             hor[i][j] += asc;             hor2[i][j] += des;           } else {             hor[i][j] += des;             hor2[i][j] += asc;           }         }         if (i > 1) {           ver[i][j] = ver[i - 1][j];           ver2[i][j] = ver2[i - 1][j];           if (con[i][j] == con[i - 1][j]) {             ver[i][j] += eq;             ver2[i][j] += eq;           } else if (con[i - 1][j] < con[i][j]) {             ver[i][j] += asc;             ver2[i][j] += des;           } else {             ver[i][j] += des;             ver2[i][j] += asc;           }         }       }     }     for ((i) = (1); (i) <= (n - 2); ++(i)) {       for ((j) = (1); (j) <= (m - 2); ++(j)) {         for ((k) = (i + 2); (k) <= (n); ++(k)) {           l = j + 2;           r = m;           while (l < r) {             mid = (l + r + 1) / 2;             a = hor[i][mid] - hor[i][j] + hor2[k][mid] - hor2[k][j];             b = ver2[k][j] - ver2[i][j] + ver[k][mid] - ver[i][mid];             cur = a + b;             if (cur < t)               l = mid;             else               r = mid - 1;           }           for ((it) = (l - 3); (it) <= (l + 3); ++(it)) {             if (it < j + 2)               continue;             else if (m < it)               break;             a = hor[i][it] - hor[i][j] + hor2[k][it] - hor2[k][j];             b = ver2[k][j] - ver2[i][j] + ver[k][it] - ver[i][it];             cur = a + b;             if (abs(cur - t) <= dif) {               dif = abs(cur - t);               ans = make_pair(make_pair(i, j), make_pair(k, it));               if (dif == 0) goto PRINT;             }           }         }       }     }   PRINT:;     printf( %d %d %d %d n , ans.first.first, ans.first.second, ans.second.first,            ans.second.second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const N = 1e6 + 2;   int a[N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     for (int i = 0; i < (int)(n); ++i) cin >> a[i];     for (int i = 0; i < (int)((1 << n)); ++i) {       long long sum = 0;       for (int j = 0; j < (int)(n); ++j)         if (i & (1 << j))           sum += a[j];         else           sum -= a[j];       sum %= 360;       if (!sum) return cout <<  YES , 0;     }     cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> ft(1, 1LL);   int n, ans[3], hg, xxx = 0;   vector<int> graph[200005], vis(200005);   queue<int> q;   void dfs(int node, int par, int i, int h) {     if (h >= hg) hg = h, ans[i] = node;     for (auto child : graph[node])       if (child != par) dfs(child, node, i, h + 1);   }   int dfs2(int node, int par, int dest) {     if (node == dest) {       q.push(node);       vis[node] = 1;       return 1;     }     for (auto child : graph[node]) {       if (child == par) continue;       if (dfs2(child, node, dest)) {         q.push(node), vis[node] = 1;         return 1;       }     }     return 0;   }   void solve() {     cin >> n;     for (long long i = 0; i < n - 1; i++) {       int node1, node2;       cin >> node1 >> node2;       graph[node1].push_back(node2), graph[node2].push_back(node1);     }     dfs(1, 0, 0, 0);     hg = 0;     dfs(ans[0], 0, 1, 0);     xxx = hg;     dfs2(ans[0], 0, ans[1]);     hg = 0;     while (q.size()) {       int p = q.front();       if (vis[p] >= hg and p != ans[0] and p != ans[1]) hg = vis[p], ans[2] = p;       q.pop();       for (auto child : graph[p]) {         if (vis[child] == 0) vis[child] = vis[p] + 1, q.push(child);       }     }     cout << xxx + hg - 1 <<   n ;     cout << ans[1] <<     << ans[2] <<     << ans[0];   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f, maxn = 200007;   const long long MOD = 1004535809;   const long long LINF = 0x3f3f3f3f3f3f3f3fLL;   const long long P = 19260817;   char nc() {     static char buf[100000], *p1 = buf, *p2 = buf;     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)                ? EOF                : *p1++;   }   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       x = ((x << 3) + (x << 1) + ch -  0 ) % MOD, ch = getchar();     return x * f;   }   void write(int x) {     if (!x) putchar( 0 );     if (x < 0) x = -x, putchar( - );     static int sta[20];     register int tot = 0;     while (x) sta[tot++] = x % 10, x /= 10;     while (tot) putchar(sta[--tot] + 48);   }   int n;   char s[maxn];   int sump[maxn], sums[maxn];   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     int f1 = 0, f2 = 0;     for (int i = 1; i <= n; i++) {       if (s[i] ==  ( ) f2 = 1;       if (f2 == 1 && s[i] ==  ) ) f1 = 1;     }     if (f1 == 0) {       printf( 0 );       return 0;     }     for (int i = 1; i <= n; i++) {       sump[i] = sump[i - 1] + (s[i] ==  ( );     }     for (int i = n; i >= 1; i--) {       sums[i] = sums[i + 1] + (s[i] ==  ) );     }     for (int i = 1; i <= n; i++) {       if (sump[i] == sums[i]) {         printf( 1 n%d n , 2 * sump[i]);         for (int j = 1; j <= i; j++) {           if (s[j] ==  ( ) printf( %d  , j);         }         for (int j = i; j <= n; j++) {           if (s[j] ==  ) ) printf( %d  , j);         }         return 0;       }     }     for (int i = 1; i <= n; i++) {       if (sump[i] == sums[i + 1]) {         printf( 1 n%d n , 2 * sump[i]);         for (int j = 1; j <= i; j++) {           if (s[j] ==  ( ) printf( %d  , j);         }         for (int j = i + 1; j <= n; j++) {           if (s[j] ==  ) ) printf( %d  , j);         }         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool bysec(const pair<int64_t, int64_t> &a, pair<int64_t, int64_t> &b) {     return a.first > b.first;   }   void solve() {     int64_t n, x, an = 0;     cin >> n;     pair<int64_t, int64_t> A[n];     for (int64_t i = 0; i < n; i++) cin >> x, A[i] = {x, i + 1};     sort(A, A + n, bysec);     for (int64_t i = 0; i < n; i++) an += i * A[i].first + 1;     cout << an <<   n ;     for (int64_t i = 0; i < n; i++) cout << A[i].second <<    ;     cout <<   n ;   }   signed main() {     int64_t T = 1;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char s[100];     int n, t;     cin >> n >> t;     if (n == 1 && t == 10)       cout << -1;     else {       if (t < 10)         s[0] = t + 48;       else         s[0] =  1 ;       for (int i = 1; i < n; i++) {         s[i] =  0 ;       }       for (int i = 0; i < n; i++) {         cout << s[i];       }     }   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long sum = 0, ff = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) ff = -1;       ch = getchar();     }     while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar();     return sum * ff;   }   const long long N = 16;   const long long mo = 1e9 + 7;   long long n, m, f[1 << N][5], g[1 << N], a[N], b[N], ans;   inline long long ksm(long long x, long long y) {     long long ret = 1;     while (y) {       if (y & 1) ret = ret * x % mo;       x = x * x % mo;       y >>= 1ll;     }     return ret;   }   signed main() {     n = read();     m = read();     for (long long i = 1; i <= n; i++) {       a[i] = read();       b[i] = read();     }     for (long long i = 1; i <= 3; i++) f[0][i] = 1;     for (long long i = 0; i < (1 << n); i++)       for (long long j = 1; j <= n; j++) {         if (i & (1 << j - 1)) continue;         for (long long k = 1; k <= 3; k++)           if (b[j] != k)             f[i | (1 << j - 1)][b[j]] =                 (f[i | (1 << j - 1)][b[j]] + f[i][k]) % mo;       }     for (long long i = 0; i < (1 << n); i++) {       long long tot = 0;       for (long long j = 1; j <= n; j++)         if (i & (1 << j - 1)) tot += a[j];       if (tot == m) ans = (ans + f[i][1] + f[i][2] + f[i][3]) % mo;     }     printf( %lld n , ans * ksm(2ll, mo - 2) % mo);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct V {     vector<int> lnk;     int p;     int countBad();   };   V tab[400000];   int V::countBad() {     int c = 0;     for (__typeof((lnk).begin()) it = (lnk).begin(); it != (lnk).end(); ++it)       if (tab[*it].p == p) ++c;     return c;   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int(i) = 0; (i) < (m); ++(i)) {       int a, b;       cin >> a >> b;       tab[a - 1].lnk.push_back(b - 1);       tab[b - 1].lnk.push_back(a - 1);     }     for (int(i) = 0; (i) < (n); ++(i)) tab[i].p = 0;     queue<int> Q;     for (int(i) = 0; (i) < (n); ++(i)) {       if (tab[i].countBad() > 1) Q.push(i);     }     while (!Q.empty()) {       int curr = Q.front();       Q.pop();       if (tab[curr].countBad() > 1) {         tab[curr].p ^= 1;         for (__typeof((tab[curr].lnk).begin()) it = (tab[curr].lnk).begin();              it != (tab[curr].lnk).end(); ++it)           Q.push(*it);       }     }     for (int(i) = 0; (i) < (n); ++(i)) {       printf( %d , tab[i].p);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   char dir[200005];   int l[200005], r[200005], ll, rl;   int ans = 0x7fffffff;   int main() {     cin >> n;     getchar();     for (int i = 1; i <= n; i++) scanf( %c , &dir[i]);     for (int i = 1; i <= n; i++)       if (dir[i] ==  L )         scanf( %d , &l[++ll]);       else         scanf( %d , &r[++rl]);     if (ll == 0 || rl == 0) {       puts( -1 );       return 0;     }     int nowl = 1, nowr = 1;     for (nowl = 1; nowl <= ll; nowl++) {       do {         nowr++;       } while (nowr <= rl && r[nowr] < l[nowl]);       nowr--;       if (l[nowl] - r[nowr] > 0) ans = min(ans, l[nowl] - r[nowr]);     }     if (ans == 0x7fffffff) {       puts( -1 );       return 0;     } else       cout << (ans >> 1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = int64_t;   using ull = uint64_t;   using ld = long double;   using vi = vector<int64_t>;   using pii = pair<int64_t, int64_t>;   ll powr(ll a, ll b) {     ll res = 1;     while (b) {       if (b & 1) res = (res * a);       a = (a * a);       b >>= 1;     }     return res;   }   void solve() {     int64_t n, k;     cin >> n >> k;     k++;     int64_t a[n];     for (int64_t i = 0; i < n; i++) {       cin >> a[i];       a[i] = powr(10, a[i]);     }     sort(a, a + n);     int64_t ans = 0;     for (int64_t i = 0; i < n - 1 && k > 0; i++) {       int64_t den = min(k, (a[i + 1] / a[i]) - 1);       ans += a[i] * den;       k -= den;     }     if (k > 0) {       ans += a[n - 1] * k;     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int64_t t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     pair<long long int, long long int> a[100005];     for (int i = 0; i < n; i++) {       cin >> a[i].first;       a[i].second = i + 1;     }     sort(a, a + n);     if (n % 2 == 0) {       cout << n / 2 << endl;     } else {       cout << n / 2 + 1 << endl;     }     for (int i = 0; i < n; i += 2) {       cout << a[i].second <<    ;     }     cout << endl << n / 2 << endl;     for (int i = 1; i < n; i += 2) {       cout << a[i].second <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<pair<int, int>> v(n);     for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second;     sort(v.begin(), v.end());     for (int i = 0; i < n - 1; i++) {       if (v[i].second > v[i + 1].second && v[i].first != v[i + 1].first) {         cout <<  Happy Alex ;         return 0;       }     }     cout <<  Poor Alex ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[2];   int main() {     ios::sync_with_stdio(false);     string s;     cin >> s;     for (int i = s.size() - 1; i >= -1; i--) {       if (i > -1) cnt[s[i] -  0 ]++;       if (s[i] ==  1  && (i == 0 || s[i - 1] ==  0 )) {         int req = cnt[1] - cnt[0];         for (int j = i; j < s.size() && s[j] ==  1  && req > 0; j++) {           cnt[0]++;           req--;           s[j] =  0 ;         }       }     }     cout << s <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int nax = 3e5 + 5;   int nxt[nax][20];   int reach[20];   int main() {     int n, q;     cin >> n >> q;     vector<int> arr(n);     for (int i = 0; i < n; i++) cin >> arr[i];     for (int bit = 0; bit < 19; bit++) reach[bit] = n;     for (int i = n - 1; i >= 0; i--) {       for (int bit = 0; bit < 19; bit++) {         nxt[i][bit] = n;       }       for (int bit = 0; bit < 19; bit++) {         if (arr[i] & (1 << bit)) {           nxt[i][bit] = min(nxt[i][bit], reach[bit]);           if (reach[bit] < n) {             for (int j = 0; j < 19; j++) {               nxt[i][j] = min(nxt[i][j], nxt[reach[bit]][j]);             }           }           reach[bit] = i;         }       }     }     while (q--) {       int x, y;       cin >> x >> y;       x--;       y--;       bool res = false;       for (int bit = 0; bit < 19; bit++) {         if (arr[y] & (1 << bit)) {           if (nxt[x][bit] <= y) {             res = true;             break;           }         }       }       (res ? cout <<  Shi n  : cout <<  Fou n );     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, ta, tb, i, ans[100005], tc, ca[2][1005];   vector<int> va[2][1005], vb[2], ve;   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int a = 0; a < k; a++) {       scanf( %d%d , &ta, &tb);       ta--;       tb--;       vb[0].push_back(ta);       vb[1].push_back(tb);       ca[0][ta]++;       ca[1][tb]++;       ans[a] = -1;     }     for (int a = 0; a < n; a++) i = max(i, ca[0][a]);     for (int a = 0; a < m; a++) i = max(i, ca[1][a]);     for (int a = 0; a < n; a++)       for (int b = 0; b < i; b++) va[0][a].push_back(-1);     for (int a = 0; a < m; a++)       for (int b = 0; b < i; b++) va[1][a].push_back(-1);     for (int a = 0; a < k; a++) {       tc = -1;       ta = -1;       tb = -1;       for (int c = 0; c < i; c++) {         if (va[0][vb[0][a]][c] == -1 && va[1][vb[1][a]][c] == -1) {           tc = c;           break;         } else if (va[1][vb[1][a]][c] == -1)           ta = c;         else if (va[0][vb[0][a]][c] == -1)           tb = c;       }       if (tc != -1) tb = tc;       ve.clear();       ve.push_back(a);       while (1) {         tc = va[ve.size() % 2][vb[ve.size() % 2][ve.back()]]                [(ve.size() & 1) ? tb : ta];         if (tc == -1) break;         ve.push_back(tc);       }       for (int c = 0; c < ve.size(); c++)         if (ans[ve[c]] != -1) {           va[c % 2][vb[c % 2][ve[c]]][ans[ve[c]]] = -1;           va[1 - c % 2][vb[1 - c % 2][ve[c]]][ans[ve[c]]] = -1;         }       for (int c = 0; c < ve.size(); c++) {         ans[ve[c]] = (c & 1) ? ta : tb;         va[c % 2][vb[c % 2][ve[c]]][(c & 1) ? ta : tb] = ve[c];         va[1 - c % 2][vb[1 - c % 2][ve[c]]][(c & 1) ? ta : tb] = ve[c];       }     }     printf( %d n , i);     for (int a = 0; a < k; a++)       printf( %d%c , ans[a] + 1, a == k - 1 ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 100;   int n, k;   long long C[maxn][maxn];   void Init() {     C[0][0] = 1;     for (int i = 1; i < maxn; ++i) {       for (int j = 0; j <= i; ++j) {         if (j == 0 || j == i) {           C[i][j] = 1;         } else {           C[i][j] = C[i - 1][j - 1] + C[i - 1][j];         }       }     }   }   int main() {     ios::sync_with_stdio(false);     Init();     while (scanf( %d%d , &n, &k) != EOF) {       long long ans = 0;       if (k >= 1) {         ans += 1;       }       if (k >= 2) {         ans += C[n][2];       }       if (k >= 3) {         ans += C[n][3] * 2;       }       if (k >= 4) {         ans += C[n][4] * 9;       }       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2147483647;   const long long LLINF = 9223372036854775807LL;   int l, r, p;   bool isprime(int x) {     for (int i = 2; i * i <= x; ++i)       if (x % i == 0) return false;     return true;   }   const int maxn = 3000010;   int a[maxn];   int acnt = 0;   bool prime[110];   void gen(long long val, int lst) {     if (lst < p) gen(val, lst + 1);     if (prime[lst] && val * lst <= r) {       a[acnt++] = val * lst;       gen(val * lst, lst);     }   }   int dp[maxn];   bool can[maxn];   int cinf = 110;   int main() {     for (int i = 0; i < 110; ++i) prime[i] = isprime(i);     scanf( %d%d%d , &l, &r, &p);     a[acnt++] = 1;     gen(1, 2);     sort(a, a + acnt);     for (int i = 0; i < acnt; ++i) dp[i] = cinf;     dp[0] = 0;     for (int j = 0; j < p; ++j) {       int ptr = 0;       for (int i = 0; i < acnt; ++i) {         if (dp[i] > p) continue;         can[i] |= dp[i] <= p;         if (a[i] * (long long)j <= r) {           int needval = a[i] * j;           while (a[ptr] != needval) ++ptr;           int wh = ptr;           dp[wh] = min(dp[wh], dp[i] + 1);         }         ++dp[i];       }     }     int ans = 0;     for (int i = 0; i < acnt; ++i)       if (a[i] >= l) ans += can[i];     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void speed() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   void convertString(string &s, char t) {     if (t ==  L ) {       for (int i = 0; s[i] !=   0 ; i++)         if (s[i] >= 65 && s[i] <= 90) s[i] += 32;     } else {       for (int i = 0; s[i] !=   0 ; i++)         if (s[i] >= 97 && s[i] <= 122) s[i] -= 32;     }   }   int compare_two_values(double a, double b) {     if (fabs(a - b) <= 1e-10) return 0;     return a > b ? 1 : -1;   }   int main() {     speed();     short n, d, c = 0;     cin >> n >> d;     for (char i =  a ; n > 0; n--) {       cout << i;       c++;       if (c == 26 || c == d)         c = 0, i =  a ;       else         i++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, ans;   bool flag = 0;   int main() {     cin >> s;     for (int i = 0; i < s.length(); ++i) {       if (s[i] ==  / ) {         if (!flag) {           ans += s[i];           flag = 1;         }       } else {         ans += s[i];         flag = 0;       }     }     if (ans.length() > 1 && ans[ans.length() - 1] ==  / )       ans = ans.substr(0, ans.length() - 1);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 7;   struct Graph {     int head[N], v[N << 1], w[N << 1], next[N << 1], e;     void clear() {       e = 0;       memset(head, -1, sizeof(head));     }     void add(int u, int v, int w) {       this->v[e] = v;       this->w[e] = w;       next[e] = head[u];       head[u] = e++;     }   } G;   int n, a[N], ans[N], id[N];   long long pre[N];   void dfs(int u, int d, long long sum) {     id[d] = u;     pre[d] = sum;     int p = lower_bound(pre + 1, pre + 1 + d, sum - a[u]) - pre;     ans[id[d - 1]]++;     ans[id[p - 1]]--;     for (int e = G.head[u]; ~e; e = G.next[e]) {       int v = G.v[e], w = G.w[e];       dfs(v, d + 1, sum + w);       ans[u] += ans[v];     }   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       scanf( %d , a + i);     }     G.clear();     for (int i = 2; i <= n; i++) {       int p, w;       scanf( %d%d , &p, &w);       G.add(p, i, w);     }     dfs(1, 1, 0);     for (int i = 1; i <= n; i++) {       printf( %d%c , ans[i],    n [i == n]);     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     set<int> vals;     set<int> cur;     for (int i = 0; i < n; ++i) {       {         set<int> cur2;         transform(cur.begin(), cur.end(), inserter(cur2, cur2.end()),                   [&a, i](int x) { return x | a[i]; });         cur = cur2;       }       cur.insert(a[i]);       copy(cur.begin(), cur.end(), inserter(vals, vals.begin()));     }     cout << vals.size() <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string p;     int i;     bool work = false;     cin >> p;     for (i = 0; i < p.size(); i++)       if (p[i] ==  H  || p[i] ==  Q  || p[i] ==  9 ) work = true;     if (work)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int q;     cin >> q;     while (q--) {       long long int n, m;       cin >> n >> m;       char s[n][m];       for (long long int i = 0; i < n; i++) {         for (long long int j = 0; j < m; j++) {           cin >> s[i][j];         }       }       long long int r[n], c[m];       for (long long int i = 0; i < n; i++) {         long long int temp = 0;         for (long long int j = 0; j < m; j++) {           if (s[i][j] ==  * ) {             temp++;           }         }         r[i] = temp;       }       for (long long int i = 0; i < m; i++) {         long long int temp = 0;         for (long long int j = 0; j < n; j++) {           if (s[j][i] ==  * ) {             temp++;           }         }         c[i] = temp;       }       long long int ans = INT_MAX;       for (long long int i = 0; i < n; i++) {         for (long long int j = 0; j < m; j++) {           long long int temp;           temp = n + m - r[i] - c[j];           if (s[i][j] ==  . ) {             temp--;           }           ans = min(ans, temp);         }       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[300005];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     int Sum = 0;     for (int i = 1; i <= n; i++) Sum += a[i];     int indx = 0;     int Taken = 0;     while (Sum > 2 * Taken) {       indx++;       Taken += a[indx];     }     cout << indx << endl;   }