malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N_MAX = 51000;   int X[N_MAX], Y[N_MAX], Z[N_MAX];   bool vis[N_MAX];   bool ff(int i, int j) {     if (X[i] != X[j]) return X[i] < X[j];     if (Y[i] != Y[j]) return Y[i] < Y[j];     return Z[i] < Z[j];   }   int main() {     int n;     cin >> n;     vector<int> P;     for (int i = 1; i <= n; i++) {       cin >> X[i] >> Y[i] >> Z[i];       P.push_back(i);     }     sort(P.begin(), P.end(), ff);     for (int i = 0; i < n - 1; i++) {       if (vis[P[i]]) continue;       if (X[P[i]] == X[P[i + 1]] and Y[P[i]] == Y[P[i + 1]]) {         vis[P[i]] = 1;         vis[P[i + 1]] = 1;         cout << P[i] <<     << P[i + 1] << endl;       }     }     for (int i = 0; i < n - 1; i++) {       if (vis[P[i]]) continue;       if (X[P[i]] != X[P[i + 1]]) continue;       int j = i + 1;       while (vis[P[j]] and j < n) {         j++;       }       if (j == n or X[P[i]] != X[P[j]]) continue;       vis[P[i]] = 1;       vis[P[j]] = 1;       cout << P[i] <<     << P[j] << endl;     }     for (int i = 0; i < n - 1; i++) {       if (vis[P[i]]) continue;       int j = i + 1;       while (vis[P[j]] and j < n) {         j++;       }       vis[P[i]] = 1;       vis[P[j]] = 1;       cout << P[i] <<     << P[j] << endl;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n;     scanf( %d , &n);     int B1, B2;     int count1 = 0;     int count2 = 0;     while (n--) {       scanf( %d %d , &B1, &B2);       if (B1 > B2) {         count1++;       }       if (B2 > B1) {         count2++;       }     }     if (count1 > count2) {       printf( Mishka );     }     if (count2 > count1) {       printf( Chris );     }     if (count2 == count1) {       printf( Friendship is magic!^^ );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   int n, m, s, t, ds, dt, cnt, f;   vector<pair<int, int>> ans;   vector<int> G[N];   pair<int, int> xx[N], yy[N];   bool vi[N];   void dfs(int u) {     vi[u] = true;     for (int v : G[u])       if (!vi[v]) {         ans.push_back({u, v});         dfs(v);       } else if (v == s)         xx[cnt] = {u, v};       else if (v == t)         yy[cnt] = {u, v};   }   int main() {     cin >> n >> m;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       G[x].push_back(y);       G[y].push_back(x);     }     cin >> s >> t >> ds >> dt;     vi[s] = true;     vi[t] = true;     for (int i = 1; i <= n; i++)       if (!vi[i]) {         dfs(i);         cnt++;       }     for (int i = 0; i < cnt; i++)       if (xx[i] == make_pair(0, 0) && yy[i] == make_pair(0, 0)) {         cout <<  No  << endl;         return 0;       } else if (xx[i] == make_pair(0, 0)) {         dt--;         ans.push_back(yy[i]);         f |= 2;       } else if (yy[i] == make_pair(0, 0)) {         ds--;         ans.push_back(xx[i]);         f |= 1;       }     if (ds <= 0 || dt <= 0) {       cout <<  No  << endl;       return 0;     }     for (int i = 0; i < cnt; i++)       if (xx[i] > make_pair(0, 0) && yy[i] > make_pair(0, 0)) {         ds--;         dt--;         ans.push_back(xx[i]);         ans.push_back(yy[i]);         f = 3;         yy[i] = {0, 0};         xx[i] = {0, 0};         break;       }     for (int i = 0; i < cnt; i++)       if (xx[i] > make_pair(0, 0) && yy[i] > make_pair(0, 0) && ds > 0) {         ds--;         ans.push_back(xx[i]);         f |= 1;         yy[i] = {0, 0};       }     for (int i = 0; i < cnt; i++)       if (xx[i] > make_pair(0, 0) && yy[i] > make_pair(0, 0) && dt > 0) {         dt--;         ans.push_back(yy[i]);         f |= 2;         xx[i] = {0, 0};       }     for (int i = 0; i < cnt; i++)       if (xx[i] > make_pair(0, 0) && yy[i] > make_pair(0, 0)) {         cout <<  No  << endl;         return 0;       }     if (ans.size() < n - 1) {       ans.push_back({s, t});       ds--;       dt--;     }     if (ds < 0 || dt < 0)       cout <<  No  << endl;     else {       cout <<  Yes  << endl;       for (auto z : ans) cout << z.first <<     << z.second << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int mod = 1000000007;   int A[13][13], B[13][13], C[13][13];   int ID[4][4];   int L, R, r1, r2;   void mul(int A[][13], int B[][13]) {     for (int i = 0; i < 13; i++)       for (int j = 0; j < 13; j++) C[i][j] = 0;     for (int k = 0; k < 13; k++)       for (int i = 0; i < 13; i++)         for (int j = 0; j < 13; j++)           C[i][j] = (C[i][j] + (long long)A[i][k] * B[k][j] % mod) % mod;     for (int i = 0; i < 13; i++)       for (int j = 0; j < 13; j++) A[i][j] = C[i][j];   }   int calc1(int R) {     if (R < 1) return 0;     for (int i = 0; i < 13; i++)       for (int j = 0; j < 13; j++) A[i][j] = 0, B[i][j] = (i == j);     for (int i = 0; i < 4; i++)       for (int j = 0; j < 4; j++)         if (i != j) {           if (i / 2 == j / 2) continue;           A[ID[i][j]][12]++;           for (int k = 0; k < 4; k++)             if (j != k) {               if (j / 2 == k / 2) continue;               if (i == 0 && j == 2 && k == 1) continue;               if (i == 1 && j == 2 && k == 0) continue;               A[ID[i][j]][ID[j][k]]++;             }         }     A[12][12] = 1;     for (int i = R - 1; i > 0; i /= 2) {       if (i & 1) mul(B, A);       mul(A, A);     }     int res = 4;     for (int i = 0; i < 12; i++) res = (res + B[i][12]) % mod;     return res;   }   int calc2(int R) {     if (R < 1) return 0;     for (int i = 0; i < 13; i++)       for (int j = 0; j < 13; j++) A[i][j] = 0, B[i][j] = (i == j);     for (int i = 0; i < 4; i++)       for (int j = 0; j < 4; j++)         if (i != j) {           if (i / 2 == j / 2) continue;           for (int k = 0; k < 4; k++)             if (j != k) {               if (j / 2 == k / 2) continue;               if (i == 0 && j == 2 && k == 1) continue;               if (i == 1 && j == 2 && k == 0) continue;               A[ID[i][j]][ID[j][k]]++;             }           A[ID[i][j]][12]++;         }     A[12][12] = 1;     for (int i = (R - 1) / 2; i; i /= 2) {       if (i & 1) mul(B, A);       mul(A, A);     }     int res = 4;     for (int i = 0; i < 12; i++) res = (res + B[i][12]) % mod;     return res;   }   int main() {     scanf( %d%d , &L, &R);     for (int i = 0, k = 0; i < 4; i++)       for (int j = 0; j < 4; j++)         if (i != j) ID[i][j] = k++;     r1 = calc1(R) - calc1(L - 1);     if (r1 < 0) r1 += mod;     r2 = calc2(R) - calc2(L - 1);     if (r2 < 0) r2 += mod;     printf( %d n , (long long)(r1 + r2) * 500000004 % mod);   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 30, Mod = 1e9 + 7;   const long long SQ = 330;   int main() {     ios::sync_with_stdio(0), cin.tie(0);     long long a, b;     cin >> a >> b;     long long ans = 0;     while (a > 0 && b > 0) {       if (a <= b)         a++, b -= 2;       else         b++, a -= 2;       if (a < 0 || b < 0) ans--;       ans++;     }     cout << ans;     return (0);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout <<  2001 n ;     for (int i = 1; i <= 1000; i++) {       cout << i <<   1   << i <<   2 n ;     }     cout <<  1 1 1 2 n ;     for (int i = 1; i <= 1000; i++) {       cout << i <<   1   << i <<   2 n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Max = 1e6 + 100;   int pa[Max << 1], son[Max << 1][27];   int deep[Max << 1], sum[Max << 1], tp[Max << 1], S[Max << 1], cnt, root, last;   char str[Max << 1];   inline int Newnode(int _deep) {     deep[++cnt] = _deep;     return cnt;   }   inline void SAM(int alp) {     int np = Newnode(deep[last] + 1);     int u = last;     S[np] = 1;     memset(son[np], 0, sizeof(son[np]));     while (u && !son[u][alp]) son[u][alp] = np, u = pa[u];     if (!u)       pa[np] = root;     else {       int v = son[u][alp];       if (deep[v] == deep[u] + 1)         pa[np] = v;       else {         int nv = Newnode(deep[u] + 1);         memcpy(son[nv], son[v], sizeof(son[v]));         pa[nv] = pa[v], pa[v] = pa[np] = nv;         while (u && son[u][alp] == v) son[u][alp] = nv, u = pa[u];       }     }     last = np;   }   inline void toposort() {     for (int i = 1; i <= deep[last]; i++) sum[i] = 0;     for (int i = 1; i <= cnt; i++) sum[deep[i]]++;     for (int i = 1; i <= deep[last]; i++) sum[i] += sum[i - 1];     for (int i = 1; i <= cnt; i++) tp[sum[deep[i]]--] = i;     for (int i = cnt; i >= 1; i--) S[pa[tp[i]]] += S[tp[i]];   }   inline void pre() { root = last = Newnode(0); }   int vis[Max], Q;   void solve(char *pat, int x) {     int len = strlen(pat);     int ans = 0, l = 0, now = root;     for (int a = 0; a < len; a++) {       int c = pat[a] -  a ;       if (son[now][c]) {         now = son[now][c];         l++;       } else {         while (now && !son[now][c]) now = pa[now];         if (!now)           now = root, l = 0;         else           l = deep[now] + 1, now = son[now][c];       }       if (a >= x && l >= x) {         int tmp = now;         while (!(deep[pa[tmp]] + 1 <= x && deep[tmp] >= x)) tmp = pa[tmp];         if (vis[tmp] != Q + 1) ans += S[tmp], vis[tmp] = Q + 1;       }     }     printf( %d n , ans);   }   int main() {     scanf( %s , str);     pre();     int len = strlen(str);     for (int a = 0; a < len; a++) SAM(str[a] -  a );     toposort();     scanf( %d , &Q);     while (Q--) {       scanf( %s , str);       len = strlen(str);       for (int b = 0; b < len; b++) str[b + len] = str[b];       str[len + len] = 0;       solve(str, len);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long pow_of_two[10000];   int create() {     unsigned long long i = 0;     unsigned long long num = 1;     while (num <= INT_MAX and num >= 0) {       num = pow(2, i);       pow_of_two[i] = num;       i++;     }   }   int main() {     int n;     cin >> n;     string str;     cin >> str;     int len = str.length();     int swapi = 0;     for (int i = len - 1; i >= 0; i--) {       if (str[i] ==  1 ) {         for (int j = i - 1; j >= 0; j--) {           if (str[j] ==  1 ) {             int left = j;             int right = i;             while (left + 1 < right) {               swap(str[right], str[right - 1]);               right--;               swapi++;             }             if (str[right] ==  1  && str[right - 1] ==  1 ) {               str[right] =  4 ;             }             break;           }         }       }     }     for (int i = 0; i < str.length(); i++) {       if (str[i] !=  4 ) cout << str[i];     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a =   , b =   ;     int n, m;     cin >> n >> m;     for (int i = 0; i < 2220; i++) {       if (i % 2 == 0) {         a +=  5 ;         b +=  4 ;       } else {         a +=  4 ;         b +=  5 ;       }     }     a +=  5 ;     b +=  5 ;     cout << a << endl;     cout << b << endl;   }
#include <bits/stdc++.h>   using namespace std;   ifstream Cin( input.txt );   ofstream Cout( output.txt );   int main() {     long long n, x, i, num = 0, m[100001], m1[100001];     m[0] = m1[0] = 0;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> m[i];       m1[i] = m[i];     }     sort(m, m + n + 1);     for (i = 1; i <= n; i++) {       if (m[i] != m1[i]) {         num++;       }     }     cout << (num <= 2 ?  YES  :  NO );   }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int x, unsigned long long int y) {     long long int res = 1;     while (y > 0) {       if (y & 1) {         res = res * x;       }       y = y >> 1;       x = x * x;     }     return res;   }   long long int powermod(long long int x, unsigned long long int y,                          long long int p) {     long long int res = 1;     x = x % p;     while (y > 0) {       if (y & 1) {         res = (res * x) % p;       }       y = y >> 1;       x = (x * x) % p;     }     return res;   }   int32_t main() {     long long int n, m;     cin >> n >> m;     vector<long long int> v, suf(m + 1);     for (long long int i = (long long int)(0); i < (long long int)(m); i++) {       long long int t;       cin >> t;       v.push_back(t);     }     long long int ok = 1;     for (long long int i = (long long int)(m - 1); i >= (long long int)(0); i--) {       suf[i] = suf[i + 1] + v[i];       if (v[i] + i > n) ok = 0;     }     if (!ok or suf[0] < n) {       cout << -1 <<   n ;       return 0;     }     for (long long int i = (long long int)(0); i < (long long int)(m); i++) {       cout << max(i + 1, n - suf[i] + 1) <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005 * 2;   struct SegmentTree {     int l, r;     int sum, lmx, rmn, ansl, ansr, ans, Ans;   } t[N << 2];   int s[N];   char ss[N];   void merge(int p) {     t[p].sum = t[p * 2].sum + t[p * 2 + 1].sum;     t[p].lmx = max(t[p * 2].lmx, t[p * 2].sum + t[p * 2 + 1].lmx);     t[p].rmn = min(t[p * 2 + 1].rmn, t[p * 2 + 1].sum + t[p * 2].rmn);     t[p].ansl = max(max(t[p * 2].ansl, t[p * 2 + 1].ansl - t[p * 2].sum),                     t[p * 2].ans + t[p * 2 + 1].lmx);     t[p].ansr = max(max(t[p * 2 + 1].ansr, t[p * 2].ansr + t[p * 2 + 1].sum),                     t[p * 2 + 1].ans - t[p * 2].rmn);     t[p].ans =         max(t[p * 2].ans + t[p * 2 + 1].sum, t[p * 2 + 1].ans - t[p * 2].sum);     t[p].Ans = max(max(max(t[p * 2].Ans, t[p * 2 + 1].Ans),                        t[p * 2 + 1].ansl - t[p * 2].rmn),                    t[p * 2].ansr + t[p * 2 + 1].lmx);   }   void build(int p, int l, int r) {     t[p].l = l, t[p].r = r;     if (l == r) {       t[p].sum = s[l];       t[p].lmx = max(s[l], 0);       t[p].rmn = min(s[l], 0);       t[p].ansl = t[p].ansr = t[p].ans = t[p].Ans = 1;       return;     }     int mid = (l + r) / 2;     build(p * 2, l, mid);     build(p * 2 + 1, mid + 1, r);     merge(p);   }   void change(int p, int x, int d) {     if (t[p].l == t[p].r) {       t[p].sum = d;       t[p].lmx = max(d, 0);       t[p].rmn = min(d, 0);       t[p].ansl = t[p].ansr = t[p].ans = t[p].Ans = 1;       return;     }     int mid = (t[p].l + t[p].r) / 2;     if (x <= mid)       change(p * 2, x, d);     else       change(p * 2 + 1, x, d);     merge(p);   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     scanf( %s , ss + 1);     for (int i = 1; i <= 2 * (n - 1); i++) s[i] = (ss[i] ==  (  ? 1 : -1);     build(1, 1, 2 * (n - 1));     printf( %d n , t[1].Ans);     for (int i = 1; i <= m; i++) {       int l, r;       scanf( %d%d , &l, &r);       if (s[l] == s[r]) {         printf( %d n , t[1].Ans);         continue;       }       change(1, l, s[r]);       change(1, r, s[l]);       swap(s[l], s[r]);       printf( %d n , t[1].Ans);     }   }
#include <bits/stdc++.h>   using namespace std;   long long a[300005];   long long s[300005];   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     int n, p, k;     cin >> n >> p >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i];       a[i] %= p;     }     map<long long, long long> cnt;     for (int i = 1; i <= n; i++) {       s[i] = a[i] * a[i] % p;       s[i] = s[i] * a[i] % p;       s[i] -= k;       s[i] = (s[i] % p + p) % p;       s[i] = s[i] * a[i] % p;       cnt[s[i]]++;     }     long long res = 0;     for (auto i : cnt) {       long long val = i.second * (i.second - 1) / 2;       res += val;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     string s;     cin >> s;     vector<string> splitted;     stringstream ss(s);     string item;     while (getline(ss, item,  , )) {       splitted.push_back(item);     }     int MAX = 1001;     vector<bool> a(MAX + 1);     for (const string& page : splitted) {       a[stoi(page)] = true;     }     vector<pair<int, int>> ret;     int p = 0;     while (p <= MAX) {       if (a[p]) {         int from = p;         int to = from;         while (a[to]) {           ++to;         }         ret.emplace_back(from, to - 1);         p = to;       } else {         ++p;       }     }     for (int i = 0; i < ret.size(); ++i) {       int from = ret[i].first;       int to = ret[i].second;       cout << from;       if (to != from) {         cout <<  -  << to;       }       if (i != ret.size() - 1) {         cout <<  , ;       }     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int l, r;   } ar[300000];   bool compare(node a, node b) {     if (a.r != b.r)       return a.r < b.r;     else       return a.l < b.l;   }   vector<pair<int, int> > vectl, vectn, temp;   int main() {     int n, i, m, flag = 0;     scanf( %d%d , &n, &m);     for (i = 0; i < m; i++) {       scanf( %d%d , &ar[i].l, &ar[i].r);     }     sort(ar, ar + m, compare);     int col = -1;     for (int j = 0; j < m; j++) {       if (ar[j].r != col) {         ar[i].l = n + 1;         ar[i].r = ar[j].r;         col = ar[j].r;         i++;       }     }     m = i;     sort(ar, ar + m, compare);     int row = ar[0].l, lastrow = 1, lastcol = ar[0].r;     i = 0;     col = ar[i].r;     while (ar[i].r == col) {       if (ar[i].l > lastrow) vectl.push_back(make_pair(lastrow, ar[i].l - 1));       lastrow = ar[i].l + 1;       i++;       if (col == 1) {         while (ar[i].r == 1) i++;         break;       }     }     col = ar[i].r;     while (i < m) {       if (ar[i].r > lastcol + 1) {         int st = vectl[0].first;         lastrow = 1;         while (ar[i].r == col) {           if (ar[i].l > lastrow && ar[i].l > st) {             vectn.push_back(make_pair(lastrow, ar[i].l - 1));           }           lastrow = ar[i].l + 1;           i++;           if (i >= m) break;         }       } else {         int j = 0;         lastrow = 1;         while (ar[i].r == col) {           while (j < vectl.size() && vectl[j].second < lastrow) j++;           if (j == vectl.size()) {             while (i < m && ar[i].r == col) i++;             break;           }           lastrow = max(vectl[j].first, lastrow);           if (ar[i].l > lastrow) {             vectn.push_back(make_pair(lastrow, ar[i].l - 1));           }           lastrow = ar[i].l + 1;           i++;           if (i >= m) break;         }       }       if (i >= m) {         vectl = vectn;         lastcol = ar[i - 1].r;         if (vectl.size() == 0) {           flag = 1;         }         break;       }       lastcol = col;       col = ar[i].r;       vectl = vectn;       vectn.clear();       if (vectl.size() == 0) {         flag = 1;         break;       }     }     if (flag == 1)       printf( -1 n );     else if (lastcol != n)       printf( %d n , n + n - 2);     else if (vectl[vectl.size() - 1].second == n)       printf( %d n , n + n - 2);     else       printf( -1 n );   }
#include <bits/stdc++.h>   using namespace std;   int n, v[100002], nr;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> v[i];     }     sort(v + 1, v + n + 1);     for (int i = 1; i <= n - 2; i++) {       if (v[i] + v[i + 1] > v[i + 2]) nr++;     }     if (nr == 0)       cout <<  NO n ;     else       cout <<  YES n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M, T;   char str[1005];   int main() {     int i, j, k;     scanf( %d , &N);     scanf( %s , str);     for (i = 0; i < N; i++)       if (str[i] ==  H ) M++;     int Mc = 1005;     k = 0;     for (i = 0; i < M; i++)       if (str[i] !=  H ) k++;     int st = 0;     if (k < Mc) Mc = k;     for (i = M; i < N; i++) {       if (str[st] !=  H ) k--;       st++;       if (str[i] !=  H ) k++;       if (k < Mc) Mc = k;     }     M = 0;     for (i = 0; i < N; i++)       if (str[i] ==  T ) M++;     k = 0;     for (i = 0; i < M; i++)       if (str[i] ==  H ) k++;     st = 0;     if (k < Mc) Mc = k;     for (i = M; i < N; i++) {       if (str[st] ==  H ) k--;       st++;       if (str[i] ==  H ) k++;       if (k < Mc) Mc = k;     }     printf( %d n , Mc);     scanf(   );   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n;     cin >> n;     long long store[100005] = {};     for (long long i = 1; i <= n; i++) {       long long x, y;       cin >> x >> y;       y = i - y;       long long ct = 0;       for (long long j = 1; j * j <= x; j++) {         if (x % j == 0) {           if (store[j] < y) ct++;           if (j != x / j && store[x / j] < y) ct++;           store[j] = i;           store[x / j] = i;         }       }       cout << ct <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T in() {     char ch;     T n = 0;     bool ng = false;     while (1) {       ch = getchar();       if (ch ==  - ) {         ng = true;         ch = getchar();         break;       }       if (ch >=  0  && ch <=  9 ) break;     }     while (1) {       n = n * 10 + (ch -  0 );       ch = getchar();       if (ch <  0  || ch >  9 ) break;     }     return (ng ? -n : n);   }   template <typename T>   inline T POW(T B, T P) {     if (P == 0) return 1;     if (P & 1)       return B * POW(B, P - 1);     else       return (POW(B, P / 2) * POW(B, P / 2));   }   template <typename T>   inline T Gcd(T a, T b) {     if (a < 0) return Gcd(-a, b);     if (b < 0) return Gcd(a, -b);     return (b == 0) ? a : Gcd(b, a % b);   }   template <typename T>   inline T Lcm(T a, T b) {     if (a < 0) return Lcm(-a, b);     if (b < 0) return Lcm(a, -b);     return a * (b / Gcd(a, b));   }   long long Bigmod(long long base, long long power, long long MOD) {     long long ret = 1;     while (power) {       if (power & 1) ret = (ret * base) % MOD;       base = (base * base) % MOD;       power >>= 1;     }     return ret;   }   bool isVowel(char ch) {     ch = toupper(ch);     if (ch ==  A  || ch ==  U  || ch ==  I  || ch ==  O  || ch ==  E )       return true;     return false;   }   template <typename T>   long long int isLeft(T a, T b, T c) {     return (a.x - b.x) * (b.y - c.y) - (b.x - c.x) * (a.y - b.y);   }   long long ModInverse(long long number, long long MOD) {     return Bigmod(number, MOD - 2, MOD);   }   bool isConst(char ch) {     if (isalpha(ch) && !isVowel(ch)) return true;     return false;   }   int toInt(string s) {     int sm;     stringstream second(s);     second >> sm;     return sm;   }   long long int a[200007];   int main() {     int n;     n = in<int>();     for (int i = 1; i < n + 1; i++) a[i] = in<long long int>();     int m;     m = in<int>();     long long int last = 0;     while (m--) {       int w, h;       w = in<int>(), h = in<int>();       long long int ans = max(last, a[w]);       printf( %lld n , ans);       last = ans + h;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, A;   int level[10], loyal[10];   double maxP;   void backtrack(int p, int k) {     if (p == n || k == 0) {       double x = 0;       for (int mask = 0; mask < (1 << n); mask++) {         int cnt = 0, B = 0;         double prob = 1.0;         for (int i = 0; i < n; i++) {           if (mask & (1 << i)) {             prob *= loyal[i] / 100.0;             cnt++;           } else {             prob *= (100 - loyal[i]) / 100.0;             B += level[i];           }         }         if (2 * cnt > n)           x += prob;         else           x += prob * A / (A + B);       }       maxP = max(maxP, x);     } else {       backtrack(p + 1, k);       if (loyal[p] < 100) {         loyal[p] += 10;         backtrack(p, k - 1);         loyal[p] -= 10;       }     }   }   int main() {     int k;     while (cin >> n >> k >> A) {       for (int i = 0; i < n; i++) cin >> level[i] >> loyal[i];       maxP = 0;       backtrack(0, k);       printf( %.10lf n , maxP);     }     return 0;   }