malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int sum, len;   string s;   int cnt[26][5010][26];   int main() {     cin >> s;     sum = 0;     len = s.length();     s += s;     memset(cnt, 0, sizeof(cnt));     for (int i = 0; i < len; i++) {       for (int j = 1; j < len; j++) {         cnt[s[i] -  a ][j][s[i + j] -  a ]++;       }     }     for (int i = 0; i < 26; i++) {       int mx = 0;       for (int j = 1; j < len; j++) {         int tmp = 0;         for (int k = 0; k < 26; k++)           if (cnt[i][j][k] == 1) tmp++;         mx = max(mx, tmp);       }       sum += mx;     }     printf( %.10lf n , (double)sum / (double)len);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int A1, B1, C1, A2, B2, C2;     cin >> A1 >> B1 >> C1 >> A2 >> B2 >> C2;     if (A1 * B2 != A2 * B1)       cout << 1 << endl;     else {       if (A1 != 0 && A2 != 0 && A2 * C1 == A1 * C2)         cout << -1 << endl;       else if (A1 != 0 && A2 != 0)         cout << 0 << endl;       else if ((A1 == 0 && A2 != 0) || (A1 != 0 && A2 == 0)) {         if (B1 != 0 && B2 != 0)           cout << 1 << endl;         else if (B1 == 0 && C1 != 0 || B2 == 0 && C2 != 0)           cout << 0 << endl;         else           cout << -1 << endl;       } else if (A1 == 0 && A2 == 0) {         if (((B1 == 0 && C1 == 0) && (B2 == 0 && C2 == 0)) ||             ((B1 != 0 || B2 != 0) && B1 * C2 == B2 * C1))           cout << -1 << endl;         else           cout << 0 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   bool vis[N];   vector<int> prime;   void sieve() {     for (int i = 2; i * i < N; i++) {       if (vis[i]) continue;       for (int j = 2; j * i < N; j++) {         vis[i * j] = 1;       }     }     for (int i = 2; i < N; i++) {       if (vis[i] == 0) prime.push_back(i);     }   }   int find(int x) {     int ans = upper_bound(prime.begin(), prime.end(), x) - prime.begin() - 1;     return ans;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     sieve();     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int ans = find(n) - find(sqrt(n)) + 1;       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Inf = (1 << 30) - 1;   const long long lInf = (1LL << 62) - 1;   const int mInf = 0x7f7f7f7f;   const int Maxn = 200010;   vector<int> a[Maxn];   pair<int, int> S[Maxn << 1];   int f[Maxn];   int t[Maxn];   int n, m, ans;   void solve(int k) {     map<int, int> M;     for (int i = 1; i <= n; i++) M[++f[i]] = i;     for (int i = 1; i <= n; i++) t[i] = a[i][k];     int cnt = 0, tot = 0, minn = Inf;     for (int i = 1; i <= n; i++) {       int tmp = M[t[i]];       if (tmp != 0 && i - tmp != 0)         S[++tot] = make_pair(i - tmp > 0 ? i - tmp : i - tmp + n, 1);       if (tmp != 0)         S[++tot] = make_pair(i - tmp + 1 > 0 ? i - tmp + 1 : i - tmp + n + 1, -1);       if (t[i] == f[i]) cnt++;     }     sort(S + 1, S + tot + 1);     minn = min(minn, n - cnt);     int p = 1;     for (int i = 1; i < n; i++) {       while (S[p].first <= i && p <= tot) cnt += S[p++].second;       minn = min(minn, i + n - cnt);     }     ans += minn;   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m;     for (int i = 1; i <= n; i++) {       a[i].push_back(0);       for (int x, j = 1; j <= m; j++) cin >> x, a[i].push_back(x);     }     for (int i = 1; i <= n; i++) f[i] = (i - 1) * m;     for (int i = 1; i <= m; i++) solve(i);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, s, f, add = 0, rund = 1;     cin >> n >> m >> s >> f;     if (s < f)       add = 1;     else       add = -1;     for (int i = 0; i < m; i++) {       int t, l, r;       cin >> t >> l >> r;       while (rund < t) {         if (s == f) break;         if (add == 1)           cout <<  R ;         else if (add == -1)           cout <<  L ;         s += add;         rund++;       }       if (s == f) continue;       if (t == rund) {         rund++;         if (s >= l && s <= r || s + add >= l && s + add <= r)           cout <<  X ;         else if (add == 1) {           cout <<  R ;           s += add;         } else if (add == -1) {           cout <<  L ;           s += add;         }       }     }     while (s != f) {       if (add == 1)         cout <<  R ;       else if (add == -1)         cout <<  L ;       s += add;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int(n);     scanf( %d , &(n));     int val[100001][2];     double arr[100001];     for (int i = 1; i <= n; i++) cin >> arr[i];     int sum = 0;     for (int i = 1; i <= n; i++) {       int t = arr[i];       if (arr[i] - t != 0) {         if (t > 0) {           val[i][0] = t;           val[i][1] = t + 1;         }         if (t < 0) {           val[i][0] = t - 1;           val[i][1] = t;         }         if (t == 0) {           if (arr[i] > 0) {             val[i][0] = 0;             val[i][1] = 1;           }           if (arr[i] < 0) {             val[i][0] = -1;             val[i][1] = 0;           }         }       } else {         val[i][0] = t;         val[i][1] = t;       }       sum += val[i][1];     }     int k = sum;     for (int i = 1; i <= n; i++) {       if (k > 0 && val[i][0] != val[i][1]) {         cout << val[i][0] <<   n ;         k--;       } else         cout << val[i][1] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   long long i, j, m, n, s, t, x, y, z, ma;   long long a[100][100], b[100][100];   long long mi(long long a, long long b) {     if (a < b)       return a;     else       return b;   }   void ss(long long x, long long y, long long shu) {     long long i, j, t;     z++;     if (z > 8000000) return;     if (shu > ma) {       for (i = 1; i <= n; i++)         for (j = 1; j <= m; j++) b[i][j] = a[i][j];       ma = shu;     }     t = mi(x + 3, n);     for (i = x; i <= t; i++)       for (j = 1; j <= m; j++)         if (a[i][j] == 0) {           if (a[i][j - 1] + a[i][j + 1] + a[i + 1][j] + a[i + 2][j] == 0 &&               j - 1 > 0 && j + 1 <= m && i + 2 <= n) {             a[i][j - 1] = shu + 1;             a[i][j + 1] = shu + 1;             a[i][j] = shu + 1;             a[i + 1][j] = shu + 1;             a[i + 2][j] = shu + 1;             ss(i, j, shu + 1);             a[i][j - 1] = 0;             a[i][j + 1] = 0;             a[i][j] = 0;             a[i + 1][j] = 0;             a[i + 2][j] = 0;           }           if (a[i][j - 1] + a[i][j + 1] + a[i - 1][j] + a[i - 2][j] == 0 &&               j - 1 > 0 && j + 1 <= m && i - 2 > 0) {             a[i][j - 1] = shu + 1;             a[i][j + 1] = shu + 1;             a[i][j] = shu + 1;             a[i - 1][j] = shu + 1;             a[i - 2][j] = shu + 1;             ss(i, j, shu + 1);             a[i][j - 1] = 0;             a[i][j + 1] = 0;             a[i][j] = 0;             a[i - 1][j] = 0;             a[i - 2][j] = 0;           }           if (a[i - 1][j] + a[i + 1][j] + a[i][j + 1] + a[i][j + 2] == 0 &&               i - 1 > 0 && i + 1 <= n && j + 2 <= m) {             a[i - 1][j] = shu + 1;             a[i + 1][j] = shu + 1;             a[i][j] = shu + 1;             a[i][j + 1] = shu + 1;             a[i][j + 2] = shu + 1;             ss(i, j, shu + 1);             a[i - 1][j] = 0;             a[i + 1][j] = 0;             a[i][j] = 0;             a[i][j + 1] = 0;             a[i][j + 2] = 0;           }           if (a[i - 1][j] + a[i + 1][j] + a[i][j - 1] + a[i][j - 2] == 0 &&               i - 1 > 0 && i + 1 <= n && j - 2 > 0) {             a[i - 1][j] = shu + 1;             a[i + 1][j] = shu + 1;             a[i][j] = shu + 1;             a[i][j - 1] = shu + 1;             a[i][j - 2] = shu + 1;             ss(i, j, shu + 1);             a[i - 1][j] = 0;             a[i + 1][j] = 0;             a[i][j] = 0;             a[i][j - 1] = 0;             a[i][j - 2] = 0;           }         }     return;   }   int main() {     while (scanf( %lld%lld , &n, &m) != EOF) {       ma = 0;       for (i = 1; i <= n; i++)         for (j = 1; j <= m; j++) {           a[i][j] = 0;           b[i][j] = 0;         }       z = 0;       ss(1, 1, 0);       printf( %lld n , ma);       for (i = 1; i <= n; i++) {         for (j = 1; j <= m; j++)           if (b[i][j] == 0)             printf( . );           else             printf( %c , b[i][j] + 64);         printf(  n );       }     }   }
#include <bits/stdc++.h>   using namespace std;   int c[100001];   int w[100001];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> c[i];     }     for (int i = 0; i < n; i++) {       cin >> w[i];     }     int ch = m;     set<pair<long long, int> > s;     long long cnt = 0;     for (int i = 0; i < n; i++) {       if (ch < c[i] % 100) {         long long mn = (100 - c[i] % 100) * w[i];         if (s.begin() != s.end() && s.begin()->first < mn) {           cnt += s.begin()->first;           ch += 100;           ch -= c[i] % 100;           s.erase(s.begin());           s.insert(make_pair((100 - c[i] % 100) * w[i], i));         } else {           ch += 100 - c[i] % 100;           cnt += mn;         }       } else {         if (c[i] % 100 != 0) {           s.insert(make_pair((100 - c[i] % 100) * w[i], i));           ch -= c[i] % 100;         }       }     }     cout << cnt << endl;     vector<bool> p(n, 0);     for (set<pair<long long, int> >::iterator it = s.begin(); it != s.end();          it++) {       p[it->second] = 1;     }     for (int i = 0; i < n; i++) {       if (p[i]) {         cout << c[i] / 100 <<     << c[i] % 100 << endl;       } else {         cout << (c[i] + 99) / 100 <<   0  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     pair<int, int> p[100];     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> p[i].first;       p[i].second = i + 1;     }     sort(p, p + n);     for (int i = 0; i < n; i++) cout << p[i].second <<    ;   }
#include <bits/stdc++.h>   int main() {     int ans = 0;     int count;     scanf( %d , &count);     for (int i = 0; i < count; i++) {       int prize;       scanf( %d , &prize);       int minTimeToPrize = std::min(prize - 1, 1000000 - prize);       ans = std::max(ans, minTimeToPrize);     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   struct Point {     int x, y;     void read() {       int a, b;       scanf( %d%d , &a, &b);       x = a + b;       y = a - b;     }     bool operator<(const Point p) const { return x != p.x ? x < p.x : y < p.y; }   } p[N];   int n;   int pre_min[N], pre_max[N];   int suf_min[N], suf_max[N];   bool check(long long mid) {     for (int l = 1, r = 1; r <= n; r++) {       while (p[r].x - p[l].x > mid && l <= n) l++;       int mx = max(pre_max[l - 1], suf_max[r + 1]);       int mn = min(pre_min[l - 1], suf_min[r + 1]);       if (mx - mn <= mid) return true;     }     return false;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) p[i].read();     sort(p + 1, p + 1 + n);     pre_min[0] = INT_MAX;     pre_max[0] = INT_MIN;     suf_min[n + 1] = INT_MAX;     suf_max[n + 1] = INT_MIN;     for (int i = 1; i <= n; i++) {       pre_max[i] = max(pre_max[i - 1], p[i].y);       pre_min[i] = min(pre_min[i - 1], p[i].y);     }     for (int i = n; i >= 1; i--) {       suf_max[i] = max(suf_max[i + 1], p[i].y);       suf_min[i] = min(suf_min[i + 1], p[i].y);     }     long long ans, low = 0, high = 1LL << 50, mid;     while (low <= high) {       mid = (low + high) >> 1;       if (check(mid))         high = mid - 1, ans = mid;       else         low = mid + 1;     }     printf( %.10f n , ans / 2.0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int NMax = 40, MMax = 200;   int N, nn, A[NMax][NMax], B[NMax];   int get(int a, int b) { return (a ^ b); }   int P(int a, int b) {     if (b)       return a * -1;     else       return a;   }   int main() {     scanf( %d , &N);     nn = (N + 1) >> 1;     for (int i = 1; i <= N; i++)       for (int j = 1; j <= N; j++) scanf( %d , &A[i][j]);     int ret = -100000000;     for (int I = 0; I < (1 << nn); I++) {       int cnt = 0;       int k = I;       for (int i = 1; i <= nn; i++) {         B[i] = (I & 1);         cnt += P(A[i][nn], B[i]);         I >>= 1;       }       I = k;       for (int i = 1; i < nn; i++) cnt += P(A[i + nn][nn], get(B[i], B[nn]));       for (int i = 1; i < nn; i++) {         int tot0 = P(A[nn][i], 0) + P(A[nn][nn + i], get(0, B[nn])),             tot1 = P(A[nn][i], 1) + P(A[nn][nn + i], get(1, B[nn]));         for (int j = 1; j < nn; j++) {           int maxx = -100000000;           for (int first = 0; first < 2; first++) {             int second = 0;             int x1 = get(first, B[j]), x2 = get(second, B[nn]),                 x3 = get(B[j], B[nn]), x4 = get(first, second), x5 = get(x1, x2);             if (get(x3, x4) == x5)               maxx =                   max(maxx, P(A[j][i], first) + P(A[j][nn + i], x1) +                                 P(A[nn + j][i], x4) + P(A[nn + j][nn + i], x5));           }           if (maxx != -100000000)             tot0 += maxx;           else             tot0 = -100000000;         }         for (int j = 1; j < nn; j++) {           int maxx = -100000000;           for (int first = 0; first < 2; first++) {             int second = 1;             int x1 = get(first, B[j]), x2 = get(second, B[nn]),                 x3 = get(B[j], B[nn]), x4 = get(first, second), x5 = get(x1, x2);             if (get(x3, x4) == x5)               maxx =                   max(maxx, P(A[j][i], first) + P(A[j][nn + i], x1) +                                 P(A[nn + j][i], x4) + P(A[nn + j][nn + i], x5));           }           if (maxx != -100000000)             tot1 += maxx;           else             tot1 = -100000000;         }         cnt += max(tot0, tot1);       }       ret = max(ret, cnt);     }     printf( %d n , ret);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long t;     cin >> t;     while (t--) {       long long a, b, c, d;       cin >> a >> b >> c >> d;       long long s1 = a + b;       long long s2 = c + d;       if (s1 > s2)         cout << s1 << endl;       else         cout << s2 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, flag = 0, j;     cin >> n;     while (n--) {       int x;       cin >> x;       flag = 0;       for (i = 0; i <= 33; i++) {         for (j = 0; j <= 14; j++) {           if (i * 3 + j * 7 == x) {             cout <<  YES  << endl;             flag = 1;             break;           }         }         if (flag == 1) break;       }       if (flag == 0) cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int N;   bool valid(int P, int d, vector<int> guess) {     if (P >= N) {       return true;     }     if (P == 0) {       if (valid(P + 1, d, guess)) return true;       guess[P] -= d;       if (valid(P + 1, d, guess)) return true;       guess[P] += d;       guess[P] += d;       if (valid(P + 1, d, guess)) return true;       guess[P] -= d;     } else {       if (guess[P] == guess[P - 1]) {         if (valid(P + 1, d, guess)) return true;       } else if ((guess[P] - d) == guess[P - 1]) {         guess[P] -= d;         if (valid(P + 1, d, guess)) return true;         guess[P] += d;       } else if ((guess[P] + d) == guess[P - 1]) {         guess[P] += d;         if (valid(P + 1, d, guess)) return true;         guess[P] -= d;       }     }     return false;   }   int main() {     cin >> N;     vector<int> V(N);     for (int i = 0; i < N; i++) cin >> V[i];     for (int d = 0; d <= 100; d++) {       if (valid(0, d, V)) {         cout << d <<   n ;         return 0;       }     }     cout << -1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     int64_t n;     cin >> n;     int64_t a[n];     for (int64_t i = 0; i < n; i++) cin >> a[i];     map<int64_t, int64_t> first;     map<int64_t, int64_t> second;     first[a[0]] = 1;     int64_t sum = 0;     for (int64_t i = 0; i < n; i++) sum += a[i];     for (int64_t i = 1; i < n; i++) second[a[i]]++;     int64_t cur = 0;     if (sum % 2) {       cout <<  NO n ;       return 0;     }     int64_t tar = sum / 2;     for (int64_t i = 0; i < n; i++) {       cur += a[i];       if (cur == tar) {         cout <<  YES n ;         return 0;       }       if (cur > tar) {         int64_t x = cur - tar;         if (first[x] > 0) {           cout <<  YES n ;           return 0;         }       }       if (cur < tar) {         int64_t x = tar - cur;         if (second[x] > 0) {           cout <<  YES n ;           return 0;         }       }       first[a[i + 1]]++;       second[a[i + 1]]--;     }     cout <<  NO n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   int n, m, q;   int a[1110][810];   char s[1100];   int ni[5] = {0, 1, 3, 2, 4};   long long pow_mod(long long a, long long e) {     long long res = 1;     for (; e; a = a * a % mod, e >>= 1)       if (e & 1) res = res * a % mod;     return res;   }   int frnum;   const int BASE = 5;   int wr[1100];   void gauss() {     for (int i = 1; i <= n; i++) {       int flag = 0;       for (int j = i; j <= m; j++)         if (a[j][i]) {           for (int k = 1; k <= n + q; k++) swap(a[j][k], a[i][k]);           flag = 1;           break;         }       if (flag == 0) {         m++;         for (int j = 1; j <= n + q; j++) a[m][j] = a[i][j], a[i][j] = 0;         continue;       }       for (int j = i + 1; j <= n + q; j++)         a[i][j] = (a[i][j] * ni[a[i][i]]) % BASE;       a[i][i] = 1;       for (int j = 1; j <= m; j++)         if (a[j][i] && j != i) {           for (int k = 1; k <= n + q; k++)             if (k != i)               a[j][k] = (a[j][k] + 5 - (a[j][i] * a[i][k]) % BASE) % BASE;           a[j][i] = 0;         }     }     for (int i = 1; i <= n; i++)       if (a[i][i] == 0) frnum++;     for (int i = 1; i <= m; i++) {       int ff = 0;       for (int j = 1; j <= n; j++)         if (a[i][j]) ff = 1;       if (ff) continue;       for (int j = n + 1; j <= n + q; j++)         if (a[i][j]) wr[j - n] = 1;     }   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %s , s + 1);       for (int j = 1; j <= m; j++) a[j][i] = s[j] -  a ;     }     scanf( %d , &q);     for (int i = 1; i <= q; i++) {       scanf( %s , s + 1);       for (int j = 1; j <= m; j++) a[j][i + n] = s[j] -  a ;     }     gauss();     for (int i = 1; i <= q; i++) {       if (wr[i])         cout << 0 << endl;       else         cout << pow_mod(5, frnum) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, a;     cin >> n >> a;     map<int, int> my;     set<int> rem;     int ca = 0;     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       if (x == a) {         ++ca;       } else {         if (rem.find(x) != rem.end()) continue;         my[x]++;         if (my[x] <= ca) {           my.erase(x);           rem.insert(x);         }       }     }     if (my.empty()) {       cout <<  -1 n ;       return 0;     } else {       for (auto it : my) {         if (it.second >= ca) {           cout << it.first <<   n ;           return 0;         }       }     }     cout <<  -1 n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int64_t n, l, d;     cin >> n >> d >> l;     int a[25001];     for (int i = 1; i <= n; i++) {       if (d > 0) {         a[i] = l;       } else {         a[i] = 1;       }       d = a[i] - d;     }     a[n] = a[n] - d;     if (a[n] <= 0 || a[n] > l) {       cout << -1;     } else {       for (int i = 1; i <= n; i++) {         cout << a[i] <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   const int INF = 0x3f3f3f3f;   const long long int INFLL = 0x3f3f3f3f3f3f3f3fll;   long long int getint() {     long long int ret = 0;     bool f = 0;     char c;     while ((c = getchar()) <  0  || c >  9 )       if (c ==  - ) f ^= 1;     while (c >=  0  && c <=  9 ) {       ret = ret * 10 + c -  0 ;       c = getchar();     }     return f ? -ret : ret;   }   using namespace std;   int k, p;   long long int l, r;   int mypow(int a, long long int b, int mod) {     int ret = 1;     for (; b; b >>= 1, a = (long long int)a * a % mod)       if (b & 1) ret = (long long int)ret * a % mod;     return ret;   }   int work() {     k = getint();     l = getint(), r = getint();     p = getint();     if (p == 2) return (k & 1) ? 0 : 1;     if (k % p == 0) return k & 1 ? mypow(mypow(2, p - 2, p), r - l, p) : 1;     int t = mypow(2, l, p - 1), ans;     t = mypow(k, t, p);     if ((t - 1) % p == 0)       ans = mypow(2, r - l + 1, p);     else {       int c = mypow(2, r - l + 1, p - 1);       c = mypow(t, c, p);       ans = (long long int)(c + p - 1) * mypow(t + p - 1, p - 2, p) % p;     }     if (k & 1) ans = (long long int)ans * mypow(mypow(2, p - 2, p), r - l, p) % p;     return ans;   }   int main() {     int T = getint();     while (T--) printf( %d n , work());   }
#include <bits/stdc++.h>   using namespace std;   long long valor[100456], solapacion[100456][320], posheavy[100456],       resp[100456], arrupd[100456];   vector<long long> v[100456], colaheavy;   bool light[100456], existe[100456];   void init() {     for (int i = 0; i < 100456; ++i) {       existe[i] = false;     }   }   void solape(long long m) {     long long auxcontador = 0;     for (int i = 0; i < colaheavy.size(); ++i) {       for (int j = 0; j < v[colaheavy[i]].size(); j++) {         existe[v[colaheavy[i]][j]] = true;       }       for (int j = 0; j < m; j++) {         auxcontador = 0;         for (int k = 0; k < v[j].size(); k++) {           if (existe[v[j][k]] == true) {             auxcontador++;           }         }         if (colaheavy[i] == j) auxcontador = 0;         solapacion[j][i] = auxcontador;       }       for (int j = 0; j < v[colaheavy[i]].size(); j++) {         existe[v[colaheavy[i]][j]] = false;       }     }   }   void updatelight(long long pos, long long val) {     pos--;     for (int i = 0; i < v[pos].size(); ++i) {       valor[v[pos][i]] += val;     }     for (int i = 0; i < colaheavy.size(); ++i) {       resp[colaheavy[i]] += (solapacion[pos][i]) * val;     }   }   void updateheavy(long long pos, long long num) {     pos--;     resp[pos] += v[pos].size() * num;     arrupd[pos] += num;   }   void querylight(long long num) {     long long tot = 0;     for (int i = 0; i < v[num].size(); ++i) {       tot += valor[v[num][i]];     }     for (int i = 0; i < colaheavy.size(); ++i) {       tot += solapacion[num][i] * arrupd[colaheavy[i]];     }     cout << tot << endl;   }   void queryheavy(long long num) {     long long tot = resp[num];     for (int i = 0; i < colaheavy.size(); ++i) {       tot += solapacion[num][i] * arrupd[colaheavy[i]];     }     cout << tot << endl;   }   int main() {     long long n, m, queries, aux, aux2, val, num;     ios_base::sync_with_stdio(false);     cin.tie(0);     string txt;     cin >> n >> m >> queries;     init();     for (int i = 0; i < n; ++i) {       cin >> valor[i];     }     for (int i = 0; i < m; ++i) {       cin >> aux;       light[i] = true;       if (aux >= sqrt(100456)) {         posheavy[i] = colaheavy.size();         colaheavy.push_back(i);         light[i] = false;       }       resp[i] = 0;       for (int j = 0; j < aux; j++) {         cin >> aux2;         aux2--;         resp[i] += valor[aux2];         v[i].push_back(aux2);       }     }     solape(m);     for (int i = 0; i < queries; ++i) {       cin >> txt;       if (txt[0] ==  ? ) {         cin >> val;         val--;         if (light[val] == true) {           querylight(val);         } else {           queryheavy(val);         }       } else {         cin >> num >> val;         if (light[num - 1] == true) {           updatelight(num, val);         } else {           updateheavy(num, val);         }       }     }   }