malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int inf = (int)1e9, maxn = (int)1e5 + 1;   const double eps = (double)1e-8;   const int mod = (int)1000000009;   int n, a[1001], x, y, xx, yy, z, my, mx;   vector<pair<int, bool> > b[3000];   string c, st;   int main() {     my = 1500;     z = 1500;     cin >> n;     x = 0;     y = 0;     for (int i = 1; i <= n; i++) {       cin >> a[i];       xx = x;       yy = y;       x += a[i];       if (i & 1) {         y += a[i];         for (int j = yy; j < y; j++)           b[z + j].push_back(make_pair(xx + j - yy, 1));       } else {         y -= a[i];         for (int j = yy - 1; j >= y; j--)           b[z + j].push_back(make_pair(xx + (yy - j - 1), 0));       }       my = max(my, y + z);     }     st =   ;     for (int i = 0; i < x; i++) st +=    ;     mx = x;     for (int i = my - 1;; i--) {       c = st;       if (b[i].size() == 0) break;       for (int j = 0; j < b[i].size(); j++) {         if (b[i][j].second)           c[b[i][j].first] =  / ;         else           c[b[i][j].first] = char(92);       }       cout << c << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int H, M, N;   set<int> a[200005];   int p[200005], seq[200005], r = 0;   int u[200005];   map<int, pair<int, int> > history;   void release(pair<int, int> P) { a[P.first].insert(P.second); }   int main(void) {     scanf( %d%d%d , &H, &M, &N);     for (int i = 0; i < H; i++) {       if (!u[i]) {         for (int c = 0, j = i; !u[j]; j = (j + M) % H, ++c) {           p[j] = r;           seq[j] = c;           a[r].insert(c);           u[j] = 1;         }         ++r;       }     }     long long ans = 0;     while (N--) {       char x[10];       int id, hash;       scanf( %s%d , x, &id);       if (x[0] ==  - )         release(history[id]);       else {         scanf( %d , &hash);         hash %= H;         int A = p[hash], B = seq[hash];         set<int>::iterator it = a[A].lower_bound(B);         if (it == a[A].end()) {           it = a[A].begin();           ans += *it + H / r - B;         } else {           ans += *it - B;         }         history[id] = make_pair(A, *it);         a[A].erase(it);       }     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9;   int main() {     int n;     cin >> n;     int graph[n][n];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         graph[i][j] = INF;       }     }     for (int i = 0; i < n - 1; i++) {       int a, b, c;       cin >> a >> b >> c;       graph[a][b] = graph[b][a] = c;     }     for (int k = 0; k < n; k++) {       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           if (graph[i][j] >= graph[i][k] + graph[k][j]) {             graph[i][j] = graph[i][k] + graph[k][j];           }         }       }     }     int ans = 0;     for (int i = 1; i < n; i++) {       if (graph[0][i] != INF) ans = max(ans, graph[0][i]);     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 300333, inf = 1011111111;   int n, m, a[max_n], used[max_n], pos, lb[max_n];   vector<int> g2[max_n], num2[max_n], g[max_n], num[max_n], k, ans;   void dfs(int v) {     used[v] = 1;     for (int i = 0; i < g2[v].size(); ++i) {       if (used[g2[v][i]] == 0) {         g[v].push_back(g2[v][i]);         num[v].push_back(num2[v][i]);         dfs(g2[v][i]);       }     }   }   void dfs2(int v) {     for (int i = 0; i < g[v].size(); ++i) {       dfs2(g[v][i]);       lb[v] ^= lb[g[v][i]];       if (lb[g[v][i]]) {         ans.push_back(num[v][i]);       }     }   }   int main() {     scanf( %d%d , &n, &m);     pos = -1;     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       if (a[i] == -1) {         pos = i;       }       if (a[i] == 1) {         k.push_back(i);       }     }     if (pos == -1 && k.size() % 2 != 0) {       printf( -1 n );       return 0;     }     for (int i = 0; i < m; ++i) {       int u, v;       scanf( %d%d , &u, &v);       g2[u].push_back(v);       g2[v].push_back(u);       num2[u].push_back(i);       num2[v].push_back(i);     }     dfs(1);     for (int i = 0; i + 1 < k.size(); i += 2) {       lb[k[i]] = 1;       lb[k[i + 1]] = 1;     }     if (k.size() % 2) {       lb[pos] = 1;       lb[k.back()] = 1;     }     dfs2(1);     printf( %d n , ans.size());     for (int i = 0; i < ans.size(); ++i) {       printf( %d n , ans[i] + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c;     int ans;     scanf( %d%d%d , &a, &b, &c);     ans = (a - b) * c;     if (!(ans % b))       ans /= b;     else {       ans /= b;       ans += 1;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 100005, INF = 1e18;   void solve() {     long long n, ans = 0, max = 0;     cin >> n;     ans = n / 2;     cout << ans <<   n ;     for (long long i = (long long)0; i < ans - 1; i++) {       cout <<  2  ;     }     if (n % 2 == 0)       cout << 2 <<   n ;     else       cout << 3 <<   n ;   }   int32_t main() {     std::ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010, maxp = 1000010;   int x[maxn], dp[maxp][20], can[maxp], f[maxp];   int n, a, b;   inline void chkmax(int& a, int b) {     if (a < b) a = b;   }   inline void chkmin(int& a, int b) {     if (a > b) a = b;   }   int getmin(int l, int r) {     int b;     for (b = 0; l + (1 << b) < r - (1 << b) + 1; b++)       ;     return min(dp[l][b], dp[r - (1 << b) + 1][b]);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &x[i]);     sort(x, x + n);     n = unique(x, x + n) - x;     scanf( %d %d , &a, &b);     swap(a, b);     for (int i = 0; i < n; i++) {       int st = a - a % x[i];       if (st != a) st += x[i];       while (st <= b) {         chkmax(can[st - a], x[i]);         st += x[i];       }     }     int length = b - a + 1;     memset(f, 0x3f, sizeof f);     dp[length - 1][0] = 0;     f[length - 1] = 0;     for (int i = length - 2; i >= 0; i--) {       int pos = min(length - 1, i + can[i] - 1);       if (can[i] > 1) chkmin(f[i], getmin(i + 1, pos) + 1);       chkmin(f[i], f[i + 1] + 1);       dp[i][0] = f[i];       for (int j = 1; i + (1 << j) <= length; j++)         dp[i][j] = min(dp[i][j - 1], dp[i + (1 << (j - 1))][j - 1]);     }     printf( %d n , f[0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> g[100000];   vector<int> rev_g[100000];   vector<int> post_order;   vector<bool> visited;   vector<int> scc;   void dfs1(int x) {     if (visited[x]) return;     visited[x] = true;     for (auto y : g[x]) dfs1(y);     post_order.push_back(x);   }   void dfs2(int x, int cc) {     if (visited[x]) return;     visited[x] = true;     scc[x] = cc;     for (auto y : rev_g[x]) dfs2(y, cc);   }   int Kosaraju() {     visited = vector<bool>(n, false);     for (int i = 0; i < n; i++) dfs1(i);     scc = vector<int>(n, -1);     visited = vector<bool>(n, false);     int cc = 0;     assert(post_order.size() == n);     reverse(post_order.begin(), post_order.end());     for (auto x : post_order)       if (scc[x] == -1) dfs2(x, cc++);     return cc;   }   set<int> par_scc[100000];   set<int> chi_scc[100000];   vector<int> scc_list[100000];   stack<int> source_scc;   int q = 0;   int pos = 0;   bool get_dir(int a, int b) {     q++;     printf( ? %d %d n , a + 1, b + 1);     fflush(stdout);     int res;     scanf( %d , &res);     if (res == 1) pos++;     return (res == 1);   }   int main() {     scanf( %d%d , &n, &m);     int v = -1, w;     for (int i = 0; i < m; i++) {       int a, b;       scanf( %d%d , &a, &b);       a--;       b--;       g[a].push_back(b);       rev_g[b].push_back(a);     }     int ncc = Kosaraju();     for (int i = 0; i < n; i++)       for (auto j : g[i])         if (scc[i] != scc[j]) {           assert(scc[i] >= 0 && scc[j] >= 0 && scc[i] < n && scc[j] < n);           par_scc[scc[j]].insert(scc[i]);           chi_scc[scc[i]].insert(scc[j]);         }     for (int i = 0; i < n; i++) scc_list[scc[i]].push_back(i);     for (int i = 0; i < ncc; i++)       if (par_scc[i].empty()) source_scc.push(i);     int cur_scc = source_scc.top();     int cur_i = 0;     int cur_size = scc_list[cur_scc].size();     source_scc.pop();     int nxt_scc, nxt_i, nxt_size;     while (!source_scc.empty()) {       nxt_scc = source_scc.top();       nxt_i = 0;       nxt_size = scc_list[nxt_scc].size();       source_scc.pop();       while (cur_i < cur_size && nxt_i < nxt_size) {         if (!get_dir(scc_list[cur_scc][cur_i], scc_list[nxt_scc][nxt_i])) {           swap(cur_scc, nxt_scc);           swap(cur_i, nxt_i);           swap(cur_size, nxt_size);         }         nxt_i++;       }       assert(nxt_i == nxt_size);       for (auto x : chi_scc[nxt_scc]) {         par_scc[x].erase(nxt_scc);         if (par_scc[x].empty()) source_scc.push(x);       }     }     printf( ! %d n , scc_list[cur_scc][cur_i] + 1);     fflush(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   int query(int x, int y) {     cout <<  1   << x <<     << y << endl;     string ans;     cin >> ans;     if (ans ==  TAK ) return 1;     return 0;   }   int find(int l, int r) {     if (l > r) return -1;     int L = l;     int R = r;     while (L < R) {       int mid = (L + R) / 2;       if (query(mid, mid + 1))         R = mid;       else         L = mid + 1;     }     return L;   }   int main() {     cin >> n >> k;     int x = find(1, n);     int y = find(1, x - 1);     if (x == 1 || !query(y, x)) y = find(x + 1, n);     cout <<  2   << x <<     << y << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, j, k, s, t;   int read() {     int x = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) ch = getchar();     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x;   }   int n1, n2, n3, p1, p2, p3, m1, m2, m3, st;   long long m, n, ans;   int st2[1010000], sta[1010000];   struct data {     int p, q;   };   bool cmp(const data &a, const data &b) { return a.p < b.p; }   struct da {     data a[50];     int n;   } a, b;   long long qpow(long long x, int y) {     long long ans = 1;     while (y) {       if (y & 1) ans *= x;       x *= x;       y >>= 1;     }     return ans;   }   void solve1(int x, long long y) {     if (y > n) return;     if (x == b.n + 1) {       ans++;       return;     }     solve1(x + 1, y);     for (int i = 1; i <= b.a[x].q; i++) y *= b.a[x].p, solve1(x + 1, y);   }   void solve2(int x, long long y, int f) {     if (!y) return;     if (x == st + 1) {       ans += y * f;       return;     }     solve2(x + 1, y, f);     for (int i = 1; i <= st2[x]; i++) y /= sta[x];     solve2(x + 1, y, -f);   }   void pre(da &a, int x) {     int i, j, k;     for (i = 1; i <= a.n; i++)       while (x % a.a[i].p == 0) x /= a.a[i].p, a.a[i].q++;     for (i = 2; i * i <= x; i++)       if (x % i == 0) {         a.n++;         a.a[a.n].p = i;         a.a[a.n].q = 0;         while (x % i == 0) x /= i, a.a[a.n].q++;       }     if (x > 1) {       a.n++;       a.a[a.n].p = x;       a.a[a.n].q = 1;     }   }   int main() {     int T = read();     while (T--) {       n1 = read();       n2 = read();       n3 = read();       n = (long long)n1 * n2 * n3;       m1 = read();       m2 = read();       m3 = read();       m = (long long)m1 * m2 * m3;       p1 = read();       p2 = read();       p3 = read();       a.n = 0;       b.n = 0;       ans = 0;       pre(a, n1);       pre(a, n2);       pre(a, n3);       pre(b, p1);       pre(b, p2);       pre(b, p3);       pre(b, 2);       sort(a.a + 1, a.a + a.n + 1, cmp);       sort(b.a + 1, b.a + b.n + 1, cmp);       solve1(1, 1);       j = 1;       st = 0;       for (i = 1; i <= a.n; i++) {         while (b.a[j].p < a.a[i].p && j <= b.n) j++;         if (j == b.n + 1) break;         if (b.a[j].p == a.a[i].p && a.a[i].q > b.a[j].q) {           sta[++st] = a.a[i].p;           st2[st] = b.a[j].q + 1;         }         if (b.a[j].p > a.a[i].p) {           sta[++st] = a.a[i].p;           st2[st] = 1;         }       }       for (; i <= a.n; i++) {         sta[++st] = a.a[i].p;         st2[st] = 1;       }       solve2(1, m, 1);       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000005;   const long long MOD = 1000000007;   long long n, k;   long long pre[MAXN], suf[MAXN], fac[MAXN], ifac[MAXN];   inline long long quick_pow(long long x, long long k) {     long long res = 1;     while (k) {       if (k & 1) (res *= x) %= MOD;       (x *= x) %= MOD;       k >>= 1;     }     return res;   }   inline void init() {     pre[0] = suf[k + 3] = fac[0] = 1;     for (int i = 1; i <= k + 2; i++) pre[i] = pre[i - 1] * (n - i) % MOD;     for (int i = k + 2; i >= 1; i--) suf[i] = suf[i + 1] * (n - i) % MOD;     for (int i = 1; i <= k + 2; i++) fac[i] = fac[i - 1] * i % MOD;     ifac[k + 2] = quick_pow(fac[k + 2], MOD - 2);     for (int i = k + 2 - 1; i >= 0; i--) ifac[i] = ifac[i + 1] * (i + 1) % MOD;   }   inline long long calc(int i, long long tmp) {     return ((k - i) & 1 ? -1 : 1) * pre[i - 1] * suf[i + 1] % MOD * ifac[i - 1] %            MOD * ifac[k + 2 - i] % MOD * tmp % MOD;   }   int main() {     cin >> n >> k;     init();     long long ans = 0, tmp = 0;     for (int i = 1; i <= k + 2; i++) {       (tmp += quick_pow(i, k)) %= MOD;       (ans += calc(i, tmp) % MOD) %= MOD;     }     cout << (ans + MOD) % MOD;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string st;   double ans = 0.0, curr = 0.0;   int flag = 0;   int main() {     cin >> st;     for (int i = 0; i < st.size(); i++) {       if ( a  <= st[i] && st[i] <=  z ) {         ans += curr;         curr = 0.0;         continue;       }       if (st[i] ==  . ) {         if (i + 3 < st.size() &&  0  <= st[i + 3] && st[i + 3] <=  9 ) {           curr = curr * 1000 + st[i + 1] * 100 + st[i + 2] * 10 + st[i + 3] -                  48 * 111;           i += 3;           continue;         }         curr += (st[i + 1] * 10 + st[i + 2] - 48 * 11) / 100.0;         i += 2;         continue;       }       curr = curr * 10 + st[i] - 48;     }     ans += curr;     string s = to_string(ans);     s.erase(s.end() - 4, s.end());     int n = s.size();     stack<char> S;     if (s[n - 1] !=  0  || s[n - 2] !=  0 )       S.push(s[n - 1]), S.push(s[n - 2]), S.push( . );     for (int i = n - 4, j = 1; i >= 0; i--, j++) {       S.push(s[i]);       if (j % 3 == 0 && i) S.push( . );     }     while (!S.empty()) cout << S.top(), S.pop();     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 10, MAXM = 1e6 + 10;   const int INF = INT_MAX, SINF = 0x3f3f3f3f;   const long long llINF = LLONG_MAX;   const int MOD = 1e9 + 7, mod = 998244353;   const int inv2 = 5e8 + 4;   long double x, y, z;   long double a[MAXN];   string s[MAXN];   int main() {     cin >> x >> y >> z;     a[1] = powl(y, z) * log(x);     a[2] = powl(z, y) * log(x);     a[3] = z * y * log(x);     a[4] = z * y * log(x);     a[5] = powl(x, z) * log(y);     a[6] = powl(z, x) * log(y);     a[7] = z * x * log(y);     a[8] = z * x * log(y);     a[9] = powl(x, y) * log(z);     a[10] = powl(y, x) * log(z);     a[11] = x * y * log(z);     a[12] = x * y * log(z);     int cnt = max_element(a + 1, a + 13) - a;     s[1] =  x^y^z ;     s[2] =  x^z^y ;     s[3] =  (x^y)^z ;     s[4] =  (x^z)^y ;     s[5] =  y^x^z ;     s[6] =  y^z^x ;     s[7] =  (y^x)^z ;     s[8] =  (y^z)^x ;     s[9] =  z^x^y ;     s[10] =  z^y^x ;     s[11] =  (z^x)^y ;     s[12] =  (z^y)^x ;     cout << s[cnt];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   int sum(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }   int sub(int a, int b) { return a - b < 0 ? a - b + MOD : a - b; }   int mul(int a, int b) { return (1LL * a * b) % MOD; }   const int MAXN = 1e6 + 7;   int shuru[MAXN], shesh[MAXN];   int zero[MAXN];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     string s;     cin >> s;     int n = s.size();     int zerosum = 1;     int sheshsum = 0;     int z = 0;     for (int i = n - 1; i >= 0; i--) {       if (s[i] ==  0 ) {         z++;         if (i + z == n) zerosum = sum(zerosum, 1);         zerosum = sub(zerosum, zero[z]);         zero[z] = shuru[i + z];         zerosum = sum(zerosum, zero[z]);       } else {         z = 0;         shesh[i] = zerosum;         sheshsum = sum(sheshsum, shesh[i]);         shuru[i] = sheshsum;       }     }     if (z == n) {       cout << n <<   n ;     } else {       cout << mul(z + 1, shuru[z]) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5E4 + 5;   const int M = N * 17 * 17;   int n, m, q, x, y, son[N], dep[N], fa[N], g[N], l[N], tot, f[N], mark[M], to[N],       ch[M][2], sum, c[N], a[N], k, b[N];   long long ans[N], tr[M], C;   vector<int> G[N];   int dfs(int x) {     int y;     son[x] = 1;     dep[x] = dep[fa[x]] + 1;     for (int i = 0; i < G[x].size(); i++) {       son[x] += dfs(y = G[x][i]);       if (son[y] > son[g[x]]) g[x] = y;     }     return son[x];   }   void dfs2(int x, int pre) {     l[x] = ++tot;     b[tot] = x;     f[x] = pre + 1;     if (g[x]) dfs2(g[x], pre);     for (int i = 0; i < G[x].size(); i++)       if (G[x][i] != g[x]) dfs2(G[x][i], tot);   }   void push_down(int p, int l, int mid, int r, int &lc, int &rc) {     if (!mark[p]) return;     if (!lc) lc = ++sum;     if (!rc) rc = ++sum;     tr[lc] += (long long)mark[p] * (mid - l + 1), mark[lc] += mark[p];     tr[rc] += (long long)mark[p] * (r - mid), mark[rc] += mark[p];     mark[p] = 0;   }   long long get(int &p, int l, int r, int x, int y, int k) {     if (x > r || y < l) return 0;     if (!p) p = ++sum;     if (x <= l && y >= r) {       int len = r - l + 1;       tr[p] += k * len;       mark[p] += k;       return tr[p] - k * len;     }     int mid = (l + r) / 2;     push_down(p, l, mid, r, ch[p][0], ch[p][1]);     long long ans =         get(ch[p][0], l, mid, x, y, k) + get(ch[p][1], mid + 1, r, x, y, k);     tr[p] = tr[ch[p][0]] + tr[ch[p][1]];     return ans;   }   void work(int x, int v, int k) {     ans[v] += (long long)c[v] * c[v] * dep[x];     for (; x;) {       ans[v] += 2ll * k *                 (get(to[v], 1, n, f[x], l[x], k) * c[v] -                  C * (dep[x] - dep[fa[b[f[x]]]])) *                 c[v];       x = fa[b[f[x]]];     }   }   int main() {     cin >> n >> m >> q >> C;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= m; i++) ans[i] = C * C * n;     for (int i = 2; i <= n; i++) {       scanf( %d , &fa[i]);       G[fa[i]].push_back(i);     }     for (int i = 1; i <= m; i++) scanf( %d , &c[i]);     dfs(1);     dfs2(1, 0);     for (int i = 1; i <= n; i++) work(i, a[i], 1);     for (int i = 1; i <= q; i++) {       scanf( %d%d , &k, &x);       if (k == 1) {         scanf( %d , &y);         work(x, a[x], -1);         work(x, y, 1);         a[x] = y;       } else         printf( %.6f n , (double)ans[x] / n);     }   }
#include <bits/stdc++.h>   using namespace std;   const int NN = 50010;   const int INF = 0x3f3f3f3f;   const int MOD = 100000, STA = 8000010;   const long long LNF = 1LL << 60;   const double EPS = 1e-8;   const double OO = 1e15;   const int dx[4] = {-1, 0, 1, 0};   const int dy[4] = {0, 1, 0, -1};   const int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   inline int sign(double x) { return (x > EPS) - (x < -EPS); }   template <class T>   T gcd(T a, T b) {     return b ? gcd(b, a % b) : a;   }   template <class T>   T lcm(T a, T b) {     return a / gcd(a, b) * b;   }   template <class T>   inline T lcm(T a, T b, T d) {     return a / d * b;   }   template <class T>   inline T Min(T a, T b) {     return a < b ? a : b;   }   template <class T>   inline T Max(T a, T b) {     return a > b ? a : b;   }   template <class T>   inline T Min(T a, T b, T c) {     return min(min(a, b), c);   }   template <class T>   inline T Max(T a, T b, T c) {     return max(max(a, b), c);   }   template <class T>   inline T Min(T a, T b, T c, T d) {     return min(min(a, b), min(c, d));   }   template <class T>   inline T Max(T a, T b, T c, T d) {     return max(max(a, b), max(c, d));   }   int N, M, T;   int n, m, x, t, w, h;   map<int, deque<int> > Q;   struct TT {     int g, p, t, id;   } E[101111];   int tp[101111], a[101111], b[101111];   bool cp(TT a, TT b) { return a.p < b.p; }   void init(int x, int now) {     for (int i = 1; i <= n; i++) {       if (E[i].g == x) Q[E[i].t - E[i].p].push_back(i);     }     for (int i = 1; i <= n; i++)       if (E[i].g != x) {         auto p = Q.find(E[i].t - E[i].p);         if (p == Q.end() || p->second.empty()) {           tp[i] = i;         } else {           tp[i] = p->second.back();           p->second.pop_back();           p->second.push_front(i);         }       }     Q.clear();   }   int main() {     scanf( %d%d%d , &n, &w, &h);     int g, p, t;     for (int i = 1; i <= n; i++) {       scanf( %d%d%d , &E[i].g, &E[i].p, &E[i].t);       E[i].id = i;     }     sort(E + 1, E + n + 1, cp);     init(1, 2);     init(2, 1);     for (int i = 1; i <= n; i++) {       if (E[i].g == 1) {         a[E[tp[i]].id] = E[i].p;         b[E[tp[i]].id] = h;       } else {         a[E[tp[i]].id] = w;         b[E[tp[i]].id] = E[i].p;       }     }     for (int i = 1; i <= n; i++) {       printf( %d %d n , a[i], b[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     ;     int n, k;     cin >> n >> k;     while (n > 0 && k > 0) {       k--;       if (n % 10 == 0)         n = n / 10;       else         n--;     }     cout << n <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long A[200005], tree[200005];   void update(int pos, long long v) {     for (; pos < 200005; pos += pos & -pos) tree[pos] += v;   }   long long read(int pos) {     long long ret = 0;     for (; pos; pos -= pos & -pos) ret += tree[pos];     return ret;   }   int main() {     ios::sync_with_stdio(false);     cout.setf(ios::fixed);     cout.precision(10);     int i, size = 1, t, n, lo, hi;     long long x, sum = 0, a;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> t;       if (t == 1) {         cin >> a >> x;         lo = 1, hi = min((long long)size, a);         update(lo, x);         update(hi + 1, -x);         sum += hi * x;       } else {         if (t == 2) {           cin >> x;           update(size + 1, x);           update(size + 2, -x);           size++;           sum += x;         } else {           if (size >= 2) {             long long val = read(size);             update(size, -val);             update(size + 1, val);             size--;             sum -= val;           }         }       }       cout << (sum * 1.0 / size) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> sg;   map<int, bool> us;   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       int x, d;       cin >> x >> d;       sg[x] = x + d;       us[x] = true;       if (us[x + d] && sg[x + d] == x && sg[x] == x + d) {         cout <<  YES n ;         return 0;       }     }     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int v = 0;     map<int, int> s;     for (int i = 19; s.size() < 10010; i += 9) {       int kk = i;       int c = 0;       while (kk > 0) {         c += kk % 10;         kk /= 10;       }       if (c == 10) s[v++] = i;     }     cout << s[n - 1];     return 0;   }