malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MXN = 100010;   const int MXX = 400050;   struct Segment_Tree {     int x, add;   } tt[MXX];   int m, v[MXN], ans[MXN];   void Build(int l, int r, int idx) {     tt[idx].x = 0;     tt[idx].add = 0;     if (l == r) {       return;     }     int mid = (l + r) >> 1;     Build(l, mid, idx << 1);     Build(mid + 1, r, idx << 1 | 1);   }   inline void PushDown(int l, int r, int idx) {     tt[idx << 1].add += tt[idx].add;     tt[idx << 1].x += tt[idx].add;     tt[idx << 1 | 1].add += tt[idx].add;     tt[idx << 1 | 1].x += tt[idx].add;     tt[idx].add = 0;   }   inline void PushUp(int l, int r, int idx) {     tt[idx].x = max(tt[idx << 1].x, tt[idx << 1 | 1].x);   }   void Change(int L, int R, int x, int l, int r, int idx) {     if (L <= l && r <= R) {       tt[idx].add += x;       tt[idx].x += x;       return;     }     PushDown(l, r, idx);     int mid = (l + r) >> 1;     if (L <= mid) Change(L, R, x, l, mid, idx << 1);     if (mid + 1 <= R) Change(L, R, x, mid + 1, r, idx << 1 | 1);     PushUp(l, r, idx);   }   int Query(int L, int R, int l, int r, int idx) {     if (L <= l && r <= R) {       return tt[idx].x;     }     PushDown(l, r, idx);     int mid = (l + r) >> 1, ans = -0x3f3f3f3f;     if (L <= mid) ans = max(ans, Query(L, R, l, mid, idx << 1));     if (mid + 1 <= R) ans = max(ans, Query(L, R, mid + 1, r, idx << 1 | 1));     PushUp(l, r, idx);     return ans;   }   int w;   inline bool Check(int x) {     int tmp = Query(x, m, 1, m, 1);     if (tmp > 0) {       w = x;       return 1;     }     return 0;   }   inline void Mybin(int low, int high) {     w = 0;     for (int mid = (low + high) >> 1; low <= high;          (Check(mid) ? low = mid + 1 : high = mid - 1), mid = (low + high) >> 1)       ;   }   inline void solve() {     int p, t, x;     scanf( %d , &m);     Build(1, m, 1);     for (int i = 1; i <= m; i++) {       scanf( %d%d , &t, &p);       if (p == 0) {         Change(1, t, -1, 1, m, 1);       } else {         scanf( %d , &x);         v[t] = x;         Change(1, t, 1, 1, m, 1);       }       Mybin(1, m);       if (w == 0)         ans[i] = -1;       else         ans[i] = v[w];     }     for (int i = 1; i <= m; i++) printf( %d n , ans[i]);   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     vector<int> values;     int T;     cin >> T;     while (T--) {       values.clear();       map<int, int> indexes;       bool flag = false;       int n, bindex;       cin >> n;       for (int i = 0; i < n; i++) {         int value;         cin >> value;         values.push_back(value);         indexes[value] = i;       }       for (int i = n; i > 0; i--) {         int j = indexes[i];         if (j != 0 && j != n - 1) {           if (values[j - 1] < i && values[j + 1] < i) {             flag = true;             bindex = j;             break;           }         }       }       if (flag) {         cout <<  YES               <<   n ;         cout << bindex <<     << bindex + 1 <<     << bindex + 2 <<   n ;       } else         cout <<  NO               <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int ret = 0, t = 1;     char c = getchar();     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     if (c ==  - ) t = -1, c = getchar();     while (c >=  0  && c <=  9 ) ret = ret * 10 + c -  0 , c = getchar();     return ret * t;   }   const int MAXN = 1001000, mod = 1e9 + 7;   int qpow(int x, int y) {     if (y < 0) return qpow(qpow(x, -y), mod - 2);     int ret = 1;     while (y) {       if (y & 1) ret = 1ll * ret * x % mod;       x = 1ll * x * x % mod;       y >>= 1;     }     return ret;   }   int k, n;   int FAC[MAXN], pre[MAXN], suf[MAXN];   int fac(int x) { return (x < 0 && (x & 1)) ? -FAC[-x] : FAC[abs(x)]; }   int main() {     k = read(), n = read();     int i, j;     FAC[0] = pre[0] = 1, suf[n + 3] = 1;     for (i = 1; i <= n + 2; i++)       FAC[i] = 1ll * FAC[i - 1] * i % mod,       pre[i] = 1ll * pre[i - 1] * (k - i) % mod;     for (i = n + 2; i >= 0; i--) suf[i] = 1ll * suf[i + 1] * (k - i) % mod;     int Y = 0, ans = 0;     for (i = 1; i <= n + 2; i++) {       Y = (Y + qpow(i, n)) % mod;       int tmp = 1ll * Y * pre[i - 1] % mod * suf[i + 1] % mod *                 qpow(fac(i - 1), -1) % mod * qpow(fac(i - n - 2), -1) % mod;       ans = (ans + tmp) % mod;     }     printf( %d n , (ans + mod) % mod);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b;     scanf( %d%d%d , &n, &a, &b);     int tmp = abs(b);     int x = tmp % n;     if (b > 0) {       int ans = a + x;       while (ans >= n) {         ans %= n;       }       if (ans == 0)         printf( %d n , n);       else         printf( %d n , ans);     } else if (b == 0)       printf( %d n , a);     else {       int ans = a - x;       if (ans <= 0)         printf( %d n , n + ans);       else         printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long q;   long long n, k, a, b;   int main() {     cin >> q;     while (q--) {       cin >> k >> n >> a >> b;       long long l = 0, r = n, mid, ans = -1;       while (l <= r) {         mid = (l + r) / 2;         if (mid * a + (n - mid) * b >= k)           r = mid - 1;         else           l = mid + 1, ans = mid;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 6, MOD = 1000000007;   long long memo[N][6][6];   int n;   string s;   bool invalid(int i, int last, int before_last) {     if (last == 1 &&         (s[i] ==  *  || s[i] ==  2  || before_last == 4 || before_last == 3)) {       return 1;     }     if (last == 2 && before_last != 4 && s[i] !=  *  && s[i] !=  ? ) {       return 1;     }     if (last == 2 && s[i] ==  *  && before_last == 4) return 1;     if (last == 3) {       if ((s[i] ==  *  && before_last != 4) ||           (s[i] ==  ?  && before_last != 4) || (s[i] !=  *  && s[i] !=  ? ))         return 1;     }     if (last == 4 && (before_last == 1 || s[i] ==  0 )) {       return 1;     }     return 0;   }   long long solve(int i, int last, int before_last) {     if (invalid(i, last, before_last)) {       return 0;     }     if (i == n) {       return 1;     }     long long &ret = memo[i][last][before_last];     if (ret != -1) {       return ret % MOD;     }     ret = 0;     if (s[i] ==  ?  && last == 0) {       if (i + 1 < n) {         if (s[i + 1] ==  * ) {           ret += solve(i + 1, 2, last) % MOD;           ret += solve(i + 1, 4, last) % MOD;         } else if (s[i + 1] ==  2 ) {           ret += solve(i + 1, 4, last) % MOD;         } else if (s[i + 1] ==  1 ) {           ret += solve(i + 1, 4, last) % MOD;           ret += solve(i + 1, 1, last) % MOD;         } else {           ret += solve(i + 1, 1, last) % MOD;           ret += solve(i + 1, 2, last) % MOD;           ret += solve(i + 1, 4, last) % MOD;         }       } else {         ret += solve(i + 1, 1, last) % MOD;         ret += solve(i + 1, 4, last) % MOD;       }     } else if (s[i] ==  ?  && last == 3) {       ret += solve(i + 1, 4, last) % MOD;     } else if (s[i] ==  ?  && last == 2) {       if (before_last == 4) {         ret += solve(i + 1, 1, last) % MOD;         ret += solve(i + 1, 2, last) % MOD;       } else if (before_last != 4) {         ret += solve(i + 1, 4, last) % MOD;       }     } else if (s[i] ==  ?  && last == 1) {       ret += solve(i + 1, 1, last) % MOD;       ret += solve(i + 1, 2, last) % MOD;     } else if (s[i] ==  ?  && last == 4) {       ret += solve(i + 1, 3, last) % MOD;       ret += solve(i + 1, 2, last) % MOD;       ret += solve(i + 1, 4, last) % MOD;     } else {       if (s[i] ==  1 ) {         ret += solve(i + 1, 2, last) % MOD;       } else if (s[i] ==  2 ) {         ret += solve(i + 1, 3, last) % MOD;       } else if (s[i] ==  0 ) {         ret += solve(i + 1, 1, last) % MOD;       } else {         ret += solve(i + 1, 4, last) % MOD;       }     }     return ret % MOD;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     memset(memo, -1, sizeof memo);     cin >> s;     n = s.size();     s +=  7 ;     cout << solve(0, 0, 0) % MOD << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct T {     int i, j, r;   } a[100];   char str[100];   int n, m, i;   int v[200][2];   bool rec(int i, int r) {     if (i >= r) return 1;     int j, k;     for (j = i + 1; j <= r; j++) {       for (k = 0; k < m; k++)         if (a[k].j >= j && a[k].j <= r && a[k].i >= i + 1 && a[k].i < j)           break;         else if (a[k].i == i && (a[k].j >= j) != a[k].r)           break;       if (k == m) {         if (j != i + 1) v[i][0] = i + 1;         v[i][1] = j;         if (rec(i + 1, j - 1) && rec(j, r)) return 1;         v[i][0] = v[i][1] = -1;         return 0;       }     }     for (k = 0; k < m; k++)       if (a[k].i == i && a[k].r) break;     if (k == m) {       v[i][0] = i + 1;       if (rec(i + 1, r)) return 1;       v[i][0] = -1;     }     return 0;   }   void print(int i) {     if (v[i][0] != -1) print(v[i][0]);     printf( %d  , i + 1);     if (v[i][1] != -1) print(v[i][1]);   }   int main() {     memset(v, -1, sizeof(v));     scanf( %d%d , &n, &m);     for (i = 0; i < m; i++) {       scanf( %d%d%s , &a[i].i, &a[i].j, &str);       a[i].i--;       a[i].j--;       if (a[i].i >= a[i].j) {         puts( IMPOSSIBLE );         return 0;       }       a[i].r = str[0] ==  R ;     }     if (!rec(0, n - 1)) {       puts( IMPOSSIBLE );       return 0;     }     print(0);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mod = 1e9 + 7;   int base[2] = {31, 33};   int pw[2][1000005], a[2][1000005];   char s[1000005];   int n, ans[1000005];   bool func(int x, int y, int xx, int yy) {     for (int i = 0; i <= 1; i++) {       if (((a[i][y] - 1ll * a[i][x - 1] * pw[i][y - x + 1]) % mod + mod) % mod !=           ((a[i][yy] - 1ll * a[i][xx - 1] * pw[i][yy - xx + 1]) % mod + mod) %               mod)         return 0;     }     return 1;   }   int main() {     scanf( %d %s , &n, s + 1);     for (int i = 0; i <= 1; i++) {       pw[i][0] = 1;       for (int j = 1; j < 1000005; j++)         pw[i][j] = 1ll * pw[i][j - 1] * base[i] % mod;       for (int j = 1; j <= n; j++)         a[i][j] = (1ll * a[i][j - 1] * base[i] + s[j] -  a ) % mod;     }     int l, r;     int up = (n + 1) / 2;     ans[up + 1] = -1;     for (int k = up; k; k--) {       l = k, r = n - k + 1;       ans[k] = ans[k + 1] + 2;       while (ans[k] >= r - l + 1) ans[k] -= 2;       while (ans[k] > 0) {         if (func(l, l + ans[k] - 1, r - ans[k] + 1, r)) break;         ans[k] -= 2;       }     }     for (int i = 1; i <= up; i++) printf( %d  , ans[i]);   }
#include<bits/stdc++.h>      using namespace std;      int main()   {       int t;          cin >> t;          while(t--)       {           int n;           cin >> n;              int arr[n];              for(int i=0; i<n; i++)           {               cin >> arr[i];           }           for(int i=0; i<n; i++)           {               if(arr[i]%2)                   cout << arr[i] <<    ;           }              for(int i=0; i<n; i++)           {               if(arr[i]%2==0)                   cout << arr[i] <<    ;           }              cout << endl;             }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void makemax(T& a, const T& b) {     if (a < b) a = b;   }   template <class T>   void makemin(T& a, const T& b) {     if (a > b) a = b;   }   int main() {     int xh, yh, xu, yu;     scanf( %d%d , &xh, &yh);     scanf( %d%d , &xu, &yu);     int n;     scanf( %d , &n);     int cnt = 0;     for (int i = (0); i < (n); ++i) {       int a, b, c;       scanf( %d%d%d , &a, &b, &c);       long long d1 = ((long long)a * xh + (long long)b * yh + c);       long long d2 = ((long long)a * xu + (long long)b * yu + c);       if (d1 < 0 && d2 > 0 || d1 > 0 && d2 < 0) ++cnt;     }     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 50, M = 1e4 + 2, OO = 0x3f3f3f3f;   int n, m, A[N], rem;   int main() {     scanf( %d %d , &n, &m);     rem = m;     for (int i = 0; i < n; ++i) {       scanf( %d , A + i);       int ans = 0;       if (A[i] >= rem) ans = 1, A[i] -= rem, rem = m;       ans += A[i] / m;       rem -= A[i] % m;       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   #pragma G++ optimize(2)   using namespace std;   long long read() {     char ch =    , last;     long long ans = 0;     while (ch <  0  || ch >  9 ) last = ch, ch = getchar();     while (ch >=  0  && ch <=  9 ) ans = ans * 10 + int(ch -  0 ), ch = getchar();     if (last ==  - ) return -ans;     return ans;   }   void write(long long x) {     if (x >= 10) write(x / 10);     putchar(x % 10 +  0 );   }   int n, a[200005], dp[200005], ans;   void init() {     n = read();     for (int i = 1; i <= n; i++) a[i] = read();   }   int main() {     init();     for (int i = 1; i <= n; i++) {       dp[i]++;       int l = 1, r = n;       while (l < r) {         int mid = (l + r) / 2;         if (mid == l) {           l++;           if (a[i] * 2 < a[l]) l--;           break;         }         if (a[i] * 2 < a[mid])           r = mid - 1;         else           l = mid;       }       if (l != i) dp[l] += dp[i];     }     for (int i = 1; i <= n; i++) ans = max(ans, dp[i]);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool solve(const string& s) {     vector<int> cnt(26, 0);     for (int i = 0; i < s.size(); ++i) ++cnt[s[i] -  a ];     int tmp = s.size() % 2;     int even = 0;     int odd = 0;     for (int i = 0; i < 26; ++i)       if (cnt[i] % 2 == 0)         ++even;       else         ++odd;     if (odd == 0 || (tmp == 1 && odd == 1)) return true;     return (s.size() % 2 ? true : false);   }   int main() {     string s;     cin >> s;     cout << (solve(s) ?  First  :  Second ) << endl;     return EXIT_SUCCESS;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, c;     while (~scanf( %d %d %d %d , &n, &a, &b, &c)) {       if (1 == n || n == 0) {         printf( 0 n );       } else if (2 == n) {         printf( %d n , min(a, b));       } else {         if (c > max(a, b)) {           printf( %d n , (n - 1) * min(a, b));         } else {           if (c > min(a, b))             printf( %d n , (n - 1) * min(a, b));           else             printf( %d n , min(a, b) + (n - 2) * c);         }       }     }     return 0;   }
//#include<bits/stdc++.h>   #include <iostream>   #include <vector>   #include <deque>   #include <queue>   #include <map>   #include <set>   #include <list>   #include <cmath>   #include <cstring>   #include <algorithm>   using namespace std;      #define fast ios_base::sync_with_stdio(0); cin.tie(0)   #define file freopen( input.txt ,  r , stdin);freopen( output.txt ,  w , stdout)   #define ff first   #define ss second   #define pb push_back   #define pf push_front   #define all(s) s.begin(),s.end()   typedef long long ll;   const double pi = acos(-1);   const ll N=5e6+5,M=1e9+7,H=31;   set<ll>st;   vector<pair<ll,ll>>v[N];   ll a[N];   int main()   {       fast;       ll i,j,k,l,n,fl=1;       cin>>n;       for(i=1;i<=n;i++)cin>>a[i];          for(i=1;i<=n;i++)       {           for(j=1;j<i;j++)           {               ll sm=a[i]+a[j];               if(!v[sm].empty())               {                   for(auto p:v[sm])                   {                       if(p.ff!=i && p.ss!=j && p.ff!=j && p.ss!=i)                       {                           fl=0;                           cout<< YES n ;                           cout<<p.ff<<   <<p.ss<<   <<i<<   <<j<<endl;                           return 0;                       }                   }               }               v[sm].pb({i,j});           }       }          fl?cout<< NO n :cout<<  ;         }
#include <bits/stdc++.h>   using namespace std;   const int MAXM = 100100;   const int MAXN = 500;   const int INF = (1 << 30);   char s[100100];   struct Edge {     int next, from, to, cap, cost;   };   struct MCMF {     Edge edge[MAXM];     int head[MAXN], countedge;     void Init(int N) {       this->N = N;       memset(head, -1, sizeof(head));       countedge = 0;     }     int N;     int inq[MAXN], dis[MAXN], pre[MAXN], ad[MAXN];     void AddEdge(const int& start, const int& end, const int& cap,                  const int& cost) {       edge[countedge].to = end;       edge[countedge].from = start;       edge[countedge].next = head[start];       edge[countedge].cap = cap;       edge[countedge].cost = cost;       head[start] = countedge++;       edge[countedge].to = start;       edge[countedge].from = end;       edge[countedge].next = head[end];       edge[countedge].cap = 0;       edge[countedge].cost = -cost;       head[end] = countedge++;     }     bool BF(int s, int t, int& flow, int& cost) {       int i;       for (i = 0; i < N; i++) dis[i] = INF;       memset(inq, 0, sizeof(inq));       dis[s] = 0;       inq[s] = 1;       pre[s] = -1;       ad[s] = INF;       queue<int> que;       que.push(s);       int u, v, temp;       while (!que.empty()) {         u = que.front();         que.pop();         inq[u] = 0;         for (temp = head[u]; temp != -1; temp = edge[temp].next) {           v = edge[temp].to;           if (edge[temp].cap && dis[v] > dis[u] + edge[temp].cost) {             dis[v] = dis[u] + edge[temp].cost;             pre[v] = temp;             ad[v] = min(ad[u], edge[temp].cap);             if (!inq[v]) {               inq[v] = 1;               que.push(v);             }           }         }       }       if (dis[t] == INF) return false;       flow += ad[t];       cost += dis[t] * ad[t];       u = t;       while (u != s) {         edge[pre[u]].cap -= ad[t];         edge[pre[u] ^ 1].cap += ad[t];         u = edge[pre[u]].from;       }       return true;     }     pair<int, int> MinC(int s, int t) {       pair<int, int> ret;       while (BF(s, t, ret.first, ret.second))         ;       return ret;     }   } f;   int cc[30];   int main() {     scanf( %s , s);     int limit = strlen(s);     int n;     scanf( %d , &n);     f.Init(n + 26 + 2);     int ss = 0, tt = n + 26 + 1;     for (int i = 0; s[i]; i++) {       cc[s[i] -  a ]++;     }     for (int i = 0; i < 26; i++) {       f.AddEdge(i + 1 + n, tt, cc[i], 0);     }     for (int i = 0; i < n; i++) {       scanf( %s , &s);       memset(cc, 0, sizeof(cc));       for (int j = 0; s[j]; j++) {         cc[s[j] -  a ]++;       }       for (int j = 0; j < 26; j++) {         f.AddEdge(i + 1, j + 1 + n, cc[j], i + 1);       }       int x;       scanf( %d , &x);       f.AddEdge(ss, i + 1, x, 0);     }     pair<int, int> ans = f.MinC(ss, tt);     if (ans.first < limit) ans.second = -1;     printf( %d n , ans.second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     long long n;     cin >> s;     cin >> n;     string t[n];     for (int i = 0; i < n; i++) cin >> t[i];     sort(t, t + n);     for (int i = 0; i < n; i++) {       if (s == t[i]) {         cout << s;         return 0;       }       if (s.length() <= t[i].length()) {         bool flag = 0;         string ans;         for (int j = 0; j < s.length(); j++) {           if (s[j] != t[i][j]) {             flag = 1;             ans = t[i];             break;           }         }         if (flag == 0) {           cout << t[i];           return 0;         }       }     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200010, maxm = 2 * maxn;   int n, m, a[maxn], L[maxn], R[maxn], dn, dep[maxn];   struct edge {     int j, d;     edge *nx;   } e[maxm], *v[maxn];   int en;   inline void add_e(int i, int j, int d) {     e[++en].nx = v[i];     v[i] = e + en;     v[i]->j = j;     v[i]->d = d;   }   struct vt {     int l, r, k, mk;     vt *c[2];   } * rt;   struct LineTree {     inline vt *nw(int l, int r) {       vt *x = new vt;       x->l = l;       x->r = r;       x->k = x->mk = 0;       x->c[0] = x->c[1] = 0;       return x;     }     void build(vt *x) {       int mid = (x->l + x->r) >> 1;       x->c[0] = nw(x->l, mid);       x->c[1] = nw(mid + 1, x->r);     }     inline void clr(int l, int r) { rt = nw(l, r); }     inline void mark(vt *x, int k) {       x->mk += k;       x->k += (x->r - x->l + 1) * k;     }     inline void push(vt *x) {       if (!x->mk) return;       mark(x->c[0], x->mk);       mark(x->c[1], x->mk);       x->mk = 0;     }     inline void upd(vt *x) { x->k = x->c[0]->k + x->c[1]->k; }     int get(vt *x, int l, int r) {       if (l > x->r || r < x->l) return 0;       if (l <= x->l && x->r <= r) return x->k;       if (!x->c[0]) build(x);       push(x);       return get(x->c[0], l, r) + get(x->c[1], l, r);     }     void add(vt *x, int l, int r, int k) {       if (l > x->r || r < x->l) return;       if (l <= x->l && x->r <= r) {         mark(x, k);         return;       }       if (!x->c[0]) build(x);       push(x);       add(x->c[0], l, r, k);       add(x->c[1], l, r, k);       upd(x);     }   } lt;   void dfs(int i, int p, int d) {     dep[i] = d;     L[i] = ++dn;     for (edge *e = v[i]; e; e = e->nx)       if (e->j != p) dfs(e->j, i, d + 1);     R[i] = dn;   }   int main() {     int i, j, k, t, ii, jj, kk, tt;     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) scanf( %d , a + i);     for (k = 1; k < n; k++) {       scanf( %d%d , &i, &j);       add_e(i, j, 0);       add_e(j, i, 0);     }     lt.clr(1, n);     dn = 0;     dfs(1, 0, 0);     for (i = 1; i <= n; i++) {       if (dep[i] & 1) a[i] = -a[i];       lt.add(rt, L[i], L[i], a[i]);     }     while (m--) {       scanf( %d , &k);       if (k == 1) {         scanf( %d%d , &i, &j);         if (dep[i] & 1) j = -j;         lt.add(rt, L[i], R[i], j);       } else {         scanf( %d , &i);         t = lt.get(rt, L[i], L[i]);         if (dep[i] & 1) t = -t;         printf( %d n , t);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   unsigned long long c[100005], t[100005], total[100005];   void solve() {     memset(total, 0, sizeof(total));     for (int i = 1; i <= n; i++) {       total[i] = total[i - 1] + c[i] * t[i];     }     unsigned long long v;     int idx = 0;     for (int i = 0; i < m; i++) {       cin >> v;       while (total[idx] < v && idx <= n) {         idx++;       }       printf( %d n , idx);     }     return;   }   int main() {     cin >> n >> m;     memset(c, 0, sizeof(c));     memset(t, 0, sizeof(t));     for (int i = 1; i <= n; i++) {       cin >> c[i] >> t[i];     }     solve();     return 0;   }