malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<string> names;   char *cnames[] = { Anka ,    Chapay ,  Cleo ,        Troll ,                      Dracul ,  Snowy ,   Hexadecimal };   int n = 7;   int id(const string &s) {     for (int i = 0; i < (int(names.size())); ++i)       if (s == names[i]) return i;   }   vector<pair<int, int> > s;   const int INF = 2000000100;   int bdif = INF, bs = 0;   int cp[7];   int pts[3];   void solve(int k = 0) {     if (k == 7) {       int ex[7];       int ngr[3] = {};       for (int i = 0; i < 7; ++i) ngr[cp[i]]++;       for (int i = 0; i < 3; ++i)         if (ngr[i] == 0) return;       for (int i = 0; i < 7; ++i) ex[i] = pts[cp[i]] / ngr[cp[i]];       int maxex = -1, minex = INF;       for (int i = 0; i < 7; ++i) {         if (maxex < ex[i]) maxex = ex[i];         if (minex > ex[i]) minex = ex[i];       }       double cdif = maxex - minex;       int cs = 0;       for (int i = 0; i < (int(s.size())); ++i)         if (cp[s[i].first] == cp[s[i].second]) ++cs;       if (cdif < bdif || (cdif == bdif && cs > bs)) bdif = cdif, bs = cs;     } else {       for (int i = 0; i < 3; ++i) {         cp[k] = i;         solve(k + 1);       }     }   }   int main() {     for (int i = 0; i < n; ++i) names.push_back(string(cnames[i]));     int k;     cin >> k;     while (k--) {       string n1, n2;       cin >> n1 >> n2 >> n2;       s.push_back(make_pair(id(n1), id(n2)));     }     cin >> pts[0] >> pts[1] >> pts[2];     solve();     cout << bdif <<     << bs << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int a, b, c, x = 0;     scanf( %d%d%d , &a, &b, &c);     if ((a + b) <= c) {       x = x + (c - (a + b)) + 1;     }     if ((b + c) <= a) {       x = x + (a - (b + c)) + 1;     }     if ((a + c) <= b) {       x = x + (b - (a + c)) + 1;     }     printf( %d , x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (a % b == 0)       return b;     else       return gcd(b, a % b);   }   long long lcm(long long a, long long b) {     double d = (double)(a * b);     return (long long)d / gcd(a, b);   }   int main() {     long long i, j, k, t, w, b, s, ans = 0;     double prdt = 1;     cin >> t >> w >> b;     long long g = gcd(w, b);     prdt = (double)w * b;     long long l = (long long)(prdt / g);     s = w;     if (s > b) s = b;     ans = s * (t / l) - 1 + min(t % l + 1, s);     long long num = ans;     long long den = t;     g = gcd(num, den);     cout << num / g <<  /  << den / g << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1 << 30;   const int mod = 998244353;   const int maxn = 2005;   string s;   long long ans = 0;   int n;   vector<pair<int, int> > edges[maxn];   int col[maxn], vis[maxn];   int isbi = 1;   void flood(int x, int curcol) {     if (vis[x]) {       if (col[x] != curcol) {         isbi = 0;       }       return;     }     vis[x] = 1;     col[x] = curcol;     for (int i = 0; i < edges[x].size(); i++) {       int u = edges[x][i].first, v = edges[x][i].second;       flood(u, curcol ^ v);     }   }   int pw(int x, int y) {     if (!y) return 1;     if (y == 1) return x;     int mid = pw(x, y >> 1);     if (y & 1) return 1ll * mid * mid % mod * x % mod;     return 1ll * mid * mid % mod;   }   int sear() {     isbi = 1;     int con = 0;     for (int i = 0; i <= 2 * n + 1; i++) {       if (!vis[i]) {         flood(i, 0);         ++con;       }     }     if (!isbi) return 0;     return pw(2, con - 1);   }   int solve(int m) {     memset(vis, 0, sizeof vis);     memset(col, -1, sizeof col);     for (int i = 0; i <= maxn - 1; i++) edges[i].clear();     for (int i = 0; i < n; i++) {       edges[i].push_back(make_pair(n - 1 - i, 0));     }     for (int i = 0; i < m; i++) {       edges[i + n].push_back(make_pair(n + (m - 1 - i), 0));     }     for (int i = m; i < n; i++) {       edges[i + n].push_back(make_pair(2 * n, 0));       edges[2 * n].push_back(make_pair(i + n, 0));     }     for (int i = 0; i < n; i++) {       if (s[n - 1 - i] ==  0 ) {         edges[i].push_back(make_pair(i + n, 0));         edges[i + n].push_back(make_pair(i, 0));       } else if (s[n - 1 - i] ==  1 ) {         edges[i].push_back(make_pair(i + n, 1));         edges[i + n].push_back(make_pair(i, 1));       }     }     edges[2 * n].push_back(make_pair(2 * n + 1, 1));     edges[2 * n + 1].push_back(make_pair(2 * n, 1));     edges[n].push_back(make_pair(2 * n + 1, 0));     edges[2 * n + 1].push_back(make_pair(n, 0));     edges[0].push_back(make_pair(2 * n + 1, 0));     edges[2 * n + 1].push_back(make_pair(0, 0));     return sear();   }   int main() {     ios::sync_with_stdio(false);     cin >> s;     n = s.size();     for (int i = 1; i < n; i++) {       ans = (ans + solve(i)) % mod;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char mp[510][510];   int minln, maxln, minrw, maxrw, cnt;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %s , mp[i] + 1);     minln = n + 1;     maxln = 0;     minrw = m + 1;     maxrw = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (mp[i][j] ==  X ) {           minln = min(i, minln);           minrw = min(j, minrw);           maxln = max(i, maxln);           maxrw = max(j, maxrw);           cnt++;         }     if (minln > maxln || minrw > maxrw ||         (maxln - minln + 1) * (maxrw - minrw + 1) != cnt)       printf( NO n );     else       printf( YES n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     vector<int> p(n);     for (int i = 0; i < n; ++i) cin >> p[i];     double ans = 0;     int cnt[102] = {0};     double loser[102] = {0};     for (int i = 0; i < n; ++i) loser[i] = 1.0;     for (int i = 1; i < n; ++i) {       ++cnt[i];       loser[i] *= 1.0 - p[i] / 100.0;     }     for (int st = n; st <= 300004; ++st) {       int bi = -1;       double pw = 0;       double win[102] = {0}, pref[102] = {0}, suf[102] = {0};       for (int i = 0; i < n; ++i) {         win[i] = 1.0 - loser[i];       }       pref[0] = win[0];       for (int i = 1; i < n; ++i) pref[i] = pref[i - 1] * win[i];       suf[n - 1] = win[n - 1];       for (int i = n - 2; i >= 0; --i) suf[i] = suf[i + 1] * win[i];       for (int i = 0; i < n; ++i) {         double curP = 1.0 * p[i] / 100 * loser[i];         if (i) curP *= pref[i - 1];         if (i + 1 < n) curP *= suf[i + 1];         if (curP > pw) {           pw = curP;           bi = i;         }       }       ans += st * pw;       cnt[bi]++;       loser[bi] *= 1.0 - p[bi] / 100.0;     }     printf( %.10lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   vector<int> adj[100005];   int col[100005], att[100005], dep[100005];   void dfs(int u, int d = 1, int p = -1) {     att[d] = u, dep[u] = d, col[u] = (d & 1) + 1;     for (int& v : adj[u])       if (v != p) {         if (dep[v] && d - dep[v] + 1 >= k) {           printf( 2 n );           printf( %d n , d - dep[v] + 1);           for (int i = dep[v]; i <= d; i++) printf( %d  , att[i]);           printf(  n );           exit(0);         } else if (!dep[v])           dfs(v, d + 1, u);         else           col[v] = (col[u] == col[v] ? 3 : col[v]);       }   }   int main() {     scanf( %d%d , &n, &m);     while (k * k < n) k++;     for (int a, b, i = 0; i < m; i++) {       scanf( %d%d , &a, &b);       adj[a].push_back(b);       adj[b].push_back(a);     }     srand(time(0));     for (int i = 1; i <= n; i++) random_shuffle(adj[i].begin(), adj[i].end());     dfs(1);     for (int c : {1, 2}) {       int cnt = count(col, col + n + 1, c);       if (cnt >= k) {         printf( 1 n );         for (int i = 1; i <= n && k; i++)           if (col[i] == c) printf( %d  , i), k--;         printf(  n );         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<vector<int> > a(n, vector<int>(n));     vector<int> b(n * n), q(n * n);     for (int i = 0; i < n * n; ++i) {       cin >> b[i];       q[i] = i;     }     do {       for (int i = 0; i < n; ++i)         for (int j = 0; j < n; ++j) a[i][j] = b[q[n * i + j]];       int s = a[0][0];       if (n == 3) {         s = a[0][0] + a[0][1] + a[0][2];         if (s != a[1][0] + a[1][1] + a[1][2]) continue;         if (s != a[2][0] + a[2][1] + a[2][2]) continue;         if (s != a[0][0] + a[1][0] + a[2][0]) continue;         if (s != a[0][1] + a[1][1] + a[2][1]) continue;         if (s != a[0][2] + a[1][2] + a[2][2]) continue;         if (s != a[0][0] + a[1][1] + a[2][2]) continue;         if (s != a[0][2] + a[1][1] + a[2][0]) continue;       }       if (n == 2) {         s = a[0][0] + a[0][1];         if (s != a[1][0] + a[1][1]) continue;         if (s != a[0][0] + a[1][0]) continue;         if (s != a[0][1] + a[1][1]) continue;         if (s != a[0][0] + a[1][1]) continue;         if (s != a[0][1] + a[1][0]) continue;       }       cout << s << endl;       for (int i = 0; i < n; ++i) {         for (int j = 0; j < n; ++j) cout << a[i][j] <<    ;         cout << endl;       }       break;     } while (next_permutation(q.begin(), q.end()));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, p1[2010][2010], p2[2010][2010], p3[2010][2010], p4[2010][2010];   int sun[2010][2010];   int dir[8][2] = {{-1, 0},  {1, 0},  {0, -1}, {0, 1},                    {-1, -1}, {-1, 1}, {1, -1}, {1, 1}};   int vis[2010][2010];   int nw, nwr, bel[4000010], cnt[4000010];   int tr[2010][2010];   void col(int x, int y, int c) {     sun[x][y] = c;     for (int k = 0; k <= 7; ++k) {       int tx = x + dir[k][0], ty = y + dir[k][1];       if (tx > 0 && tx <= n && ty > 0 && ty <= m && p1[tx][ty] && p2[tx][ty] &&           !sun[tx][ty]) {         col(tx, ty, c);       }     }   }   void hehe(int x, int y, int c) {     tr[x][y] = c;     for (int k = 0; k <= 7; ++k) {       int tx = x + dir[k][0], ty = y + dir[k][1];       if (tx > 0 && tx <= n && ty > 0 && ty <= m) {         if (sun[tx][ty])           bel[c] = sun[tx][ty];         else if (p1[tx][ty] && !tr[tx][ty])           hehe(tx, ty, c);       }     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) scanf( %d , &p1[i][j]), p2[i][j] = p1[i][j];     for (int k = 1; k <= 3; ++k) {       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= m; ++j) p3[i][j] = 0;       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= m; ++j) {           int tmp = 1;           for (int l = 0; l <= 7; ++l) {             int ti = i + dir[l][0], tj = j + dir[l][1];             if (ti > 0 && ti <= n && tj > 0 && tj <= m) {               if (p2[ti][tj] == 0) tmp = 0;             }           }           p3[i][j] = tmp;         }       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= m; ++j) swap(p2[i][j], p3[i][j]);     }     for (int k = 1; k <= 6; ++k) {       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= m; ++j) p3[i][j] = 0;       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= m; ++j) {           int tmp = 0;           for (int l = 0; l <= 7; ++l) {             int ti = i + dir[l][0], tj = j + dir[l][1];             if (ti > 0 && ti <= n && tj > 0 && tj <= m) {               if (p2[ti][tj] == 1) tmp = 1;             }           }           p3[i][j] = tmp;         }       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= m; ++j) swap(p2[i][j], p3[i][j]);     }     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (p1[i][j] && p2[i][j] && !sun[i][j]) col(i, j, ++nw);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (p1[i][j] && !sun[i][j] && !tr[i][j]) hehe(i, j, ++nwr);     for (int i = 1; i <= nwr; ++i) ++cnt[bel[i]];     vector<int> huhu;     for (int i = 1; i <= nw; ++i) huhu.push_back(cnt[i]);     sort(huhu.begin(), huhu.end());     printf( %d n , nw);     for (int i = 0; i < huhu.size(); ++i)       printf( %d%c , huhu[i], i + 1 == huhu.size() ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1000000007 + 1;   const int N = 200000;   long long a[200006], b[200006];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     long long mx = 0;     int cnt2 = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       mx = max(mx, a[i]);       if (a[i] == 0) cnt2++;     }     int cnt = 0;     for (int i = 0; i < n; i++)       if (mx == a[i]) cnt++;     if (cnt == n) {       if (cnt2 == n) {         cout <<  YES  <<   n ;         for (int i = 1; i <= n; i++) cout << 1 <<    ;         cout <<   n ;         return 0;       }       cout <<  NO  <<   n ;       return 0;     }     int j = -1;     for (int i = 1; i < n; i++)       if (a[i - 1] < a[i] && a[i] == mx) {         j = i;         break;       }     if (j == -1) j = 0;     cout <<  YES  <<   n ;     b[j] = a[j];     int f = (j - 1 + n) % n;     b[f] = 2LL * b[j] + a[f];     int u = j;     j = (j - 2 + n) % n;     while (j != u) {       b[j] = a[j] + b[(j + 1) % n];       j = (j - 1 + n) % n;     }     for (int i = 0; i < n; i++) cout << b[i] <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 100100;   int st[20][MAXN];   char str[MAXN];   int n;   void SparseTable() {     for (int i = 0; i < n; i++) st[0][i] = i;     for (int j = 1; (1 << j) < n; j++)       for (int i = 0; i + (1 << (j - 1)) < n; i++)         st[j][i] = (str[st[j - 1][i]] >= str[st[j - 1][i + (1 << (j - 1))]]                         ? st[j - 1][i]                         : st[j - 1][i + (1 << (j - 1))]);   }   int get(int x, int y) {     int k = int(log(double(y - x + 1)) / log(2.0));     return (str[st[k][x]] >= str[st[k][y - (1 << k) + 1]]                 ? st[k][x]                 : st[k][y - (1 << k) + 1]);   }   int main() {     scanf( %s , str);     n = strlen(str);     SparseTable();     int p = 0;     while (p != n) {       p = get(p, n - 1);       printf( %c , str[p]);       p++;     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d %d , &n, &m);     vector<pair<int, int> > f(n);     vector<int> b(m);     vector<int> array(1000005, 0);     for (int i = 0; i < n; i++) {       int temp;       scanf( %d , &temp);       array[temp]++;       f.push_back(make_pair(temp, i));     }     int ambuiguity = 0;     int impossible = 0;     sort(f.begin(), f.end());     vector<int> ans;     for (int i = 0; i < m; i++) {       int temp;       scanf( %d , &temp);       vector<pair<int, int> >::iterator it =           upper_bound(f.begin(), f.end(), make_pair(temp, -1));       if (it == f.end()) {         impossible = 1;         break;       }       if (it->first == temp) {         if (array[temp] > 1) {           ambuiguity = 1;         } else {           ans.push_back(it->second + 1);         }       } else {         impossible = 1;         break;       }     }     if (impossible == 1) {       cout <<  Impossible  << endl;     } else if (ambuiguity == 1) {       cout <<  Ambiguity  << endl;     } else {       cout <<  Possible  << endl;       for (int i = 0; i < ans.size() - 1; i++) {         printf( %d  , ans[i]);       }       cout << ans[ans.size() - 1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     int cnt = 0, val;     for (int k = 0; k < n; k++) {       cin >> val;       cnt += val;     }     if (n == 1 && val == 1)       cout <<  YES ;     else if (cnt == n - 1 && n != 1)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int INF = 1000000005;   long long INFF = 1000000000000000005LL;   int main() {     long long s, n;     cin >> s >> n;     long long x, y;     vector<pair<long long, long long>> strengths;     for (long long i = 0; i < n; i++) {       cin >> x >> y;       strengths.push_back(make_pair(x, y));     }     sort(strengths.begin(), strengths.end());     bool win = true;     for (long long i = 0; i < n; i++) {       if (s <= strengths[i].first) {         win = false;         break;       }       s += strengths[i].second;     }     if (win) {       cout <<  YES             <<   n ;       ;     } else {       cout <<  NO             <<   n ;       ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int length;     bool true_false;     char S[100], aux, digits[4] =  123 ;     cin >> S;     length = strlen(S);     for (int i = 0, x = 0, j; i < length; i += 2) {       true_false = false;       if (S[i] != digits[x]) {         for (j = i + 2; j < length; j += 2) {           if (S[i] != digits[x]) {             if (S[j] == digits[x]) {               aux = S[i];               S[i] = S[j];               S[j] = aux;               i += 2;             } else {               if (j == length - 1) {                 true_false = true;               }             }           } else {             i += 2;           }         }       }       if (true_false) {         x++;         i -= 2;       }     }     for (int i = 0, x = 0, j; i < length; i += 2) {       if (S[i] != digits[x]) {         x++;         if (S[i] != digits[x]) {           for (j = i + 2; j < length; j++) {             if (S[j] == S[i]) {               aux = S[j - 2];               S[j - 2] = S[i];               S[i] = aux;               break;             }           }         }       }     }     cout << S << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long k, n, a, b, val;   void solve() {     cin >> k >> n >> a >> b;     k -= a * n;     if (k <= 0) {       k *= -1, k++;       val = (k + a - b - 1) / (a - b);       if (val > n) {         cout << -1 << endl;         return;       }       n -= val;     }     cout << n << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char arr[108];   int main() {     int i, j, k, t, n, m, a, b, c, x, y, z;     cin >> n;     int flag = 0;     for (i = 1; i <= n; i++) {       cin >> arr[i];     }     int gap, cnt = 0;     for (i = 1; i <= n; i++) {       if (arr[i] ==  * ) {         for (j = i + 1; j <= i + n / 4; j++) {           if (arr[j] ==  * ) {             cnt = 0;             gap = j - i;             for (k = j; k <= n; k += gap) {               if (arr[k] ==  * ) {                 cnt++;                 if (cnt >= 4) {                   flag = 1;                   break;                 }               } else                 break;             }           }           if (flag == 1) break;         }         if (flag == 1) break;       }     }     if (flag == 1)       cout <<  yes ;     else       cout <<  no ;     return 0;   }
#include <stdio.h>   #include <math.h>   #include<bits/stdc++.h>   using namespace std;         // C = a^2 - b and C^2 = a^2 + b^2 hence (a^2 - b)^2 = a^2 + b^2 , evaluate and subtract then, a^2 = 2*b+1   // Since a^2 - b = C , then 2*b+1 - b = C , then C = b+1 !!!!! , We can observe that the difference between b and c are just 1   // b and c are nearly equal , so we must find integer  a  so that its square is odd number since odd / 2 gives you two numbers   // the floor and the ceil , which are basically b and b+1 -> b and c ^^      int main() {             int t;          scanf( %d ,&t);          while(t--) {              int n;              scanf( %d ,&n);              int odd_Square = sqrt(n << 1); // --> sqrt ( n / 2 );              printf( %d n ,(odd_Square-1) >> 1); // --> (odd_Square - 1) / 2 ;          }          return 0;      }
#include <bits/stdc++.h>   const int mod = 1000000007;   int k, w;   int fac[1000010];   int invfac[1000010];   inline int gcd(int a, int b, int &x, int &y) {     if (b == 0) {       x = 1;       y = 0;       return a;     }     int d = gcd(b, a % b, x, y);     int t = x;     x = y;     y = t - a / b * y;     return d;   }   inline int inv(int a) {     int x, y, d = gcd(a, -mod, x, y);     return ((long long)x * d % mod + mod) % mod;   }   inline int perm(int a, int b) {     if (b > a || b < 0) return 0;     return (long long)fac[a] * invfac[a - b] % mod;   }   inline int pow(int a, int b) {     int g = 1;     for (; b; b >>= 1) {       if (b & 1) g = (long long)g * a % mod;       a = (long long)a * a % mod;     }     return g;   }   void predo() {     fac[0] = 1;     for (int i = 1; i <= k; i++) fac[i] = (long long)fac[i - 1] * i % mod;     invfac[k] = inv(fac[k]);     for (int i = k - 1; i >= 0; i--)       invfac[i] = (long long)invfac[i + 1] * (i + 1) % mod;   }   int solve() {     int maxl = k + w, minl = w + 1;     int ans = 0;     predo();     for (int l = minl; l <= maxl; l++) {       int tmp;       if (w * 2 > l + 1) {         int sl = l - w;         int midl = 2 * w - l;         tmp = (long long)perm(k, sl) * perm(k, sl) % mod * pow(k, midl - 2) %               mod *               ((long long)k * k % mod - (long long)(k - sl) * (k - sl) % mod +                mod) %               mod;       } else if (w * 2 == l + 1) {         int sl = w - 1;         int midl = 1;         tmp = (long long)k *               ((long long)perm(k, sl) * perm(k, sl) % mod -                (long long)perm(k - 1, sl) * perm(k - 1, sl) % mod + mod) %               mod;       } else {         int sl = w;         int midl = l - 2 * w;         int k2 = k - midl;         tmp =             ((long long)perm(k, midl) * perm(k2, sl) % mod * perm(k2, sl) % mod -              (long long)perm(k, midl + 2) * perm(k2 - 2, sl - 1) % mod *                  perm(k2 - 2, sl - 1) % mod +              mod) %             mod;       }       ans = (ans + tmp) % mod;     }     return ans;   }   int main() {     scanf( %d %d n , &k, &w);     printf( %d n , solve());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1 << 18;   int n, r;   double sum = 0;   long long c[MAXN + 10];   int main() {     scanf( %d%d , &n, &r);     for (int i = 0; i < (1 << n); i++) {       scanf( %lld , &c[i]);       sum += c[i];     }     double dv = 1 << n;     printf( %.9lf n , sum / dv);     for (int i = 0; i < r; i++) {       int z;       long long x;       scanf( %d%lld , &z, &x);       sum += x - c[z];       c[z] = x;       printf( %.9lf n , sum / dv);     }   }
#include <bits/stdc++.h>   using namespace std;   bool exceed(long long x, long long y, long long m) { return x >= m / y + 1; }   long long n, k;   long long a[105];   vector<long long> vec;   int main(void) {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> k;     for (long long(i) = (1); (i) <= (k); (i)++) cin >> a[i];     for (long long(i) = (1); (i) <= (n); (i)++) vec.push_back(i);     long long p = 0;     for (long long(i) = (1); (i) <= (k); (i)++) {       long long np = (p + a[i]) % (long long)vec.size();       cout << vec[np] <<    ;       vec.erase(vec.begin() + np);       p = np % (long long)vec.size();     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e2 + 10;   long long int n, m, x, y, cnt[M][M], ask, mx, mn = 1e18;   void go(long long int k, long long int i, long long int j, long long int dir) {     if (k == 0) return;     cnt[i][j]++;     if (j < m)       go(k - 1, i, j + 1, dir);     else if (dir == 1 && i < n)       go(k - 1, i + 1, 1, dir);     else if (dir == -1)       go(k - 1, i - 1, 1, dir);     else if (i == n)       go(k - 1, i - 1, 1, -1);   }   int main() {     long long int k, K;     cin >> n >> m >> K >> x >> y;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         if (n == 1)           cnt[i][j] = K / m;         else if (i == 1)           cnt[i][j] = K / ((2 * n - 2) * m);         else if (i == n)           cnt[i][j] = K / ((2 * n - 2) * m);         else           cnt[i][j] = (K / ((2 * n - 2) * m)) * 2;         ask += cnt[i][j];       }     K -= ask;     go(K, 1, 1, 1);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         mx = max(mx, cnt[i][j]), mn = min(mn, cnt[i][j]);     cout << mx <<     << mn <<     << cnt[x][y];     return 0;   }