malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int ls[2005], rs[2005], fa[2005], sz[2005], z[2005];   int id, n, m, rt, mn, Sz;   char s[10];   void getrt(int x, int F) {     sz[x] = 1;     int mx = 0;     if (ls[x] && ls[x] != F && !z[ls[x]]) {       getrt(ls[x], x);       sz[x] += sz[ls[x]];       if (sz[ls[x]] > mx) mx = sz[ls[x]];     }     if (rs[x] && rs[x] != F && !z[rs[x]]) {       getrt(rs[x], x);       sz[x] += sz[rs[x]];       if (sz[rs[x]] > mx) mx = sz[rs[x]];     }     if (fa[x] && fa[x] != F && !z[fa[x]]) {       getrt(fa[x], x);       sz[x] += sz[fa[x]];       if (sz[fa[x]] > mx) mx = sz[fa[x]];     }     if (Sz - sz[x] > mx) mx = Sz - sz[x];     if (mx < mn || (mx == mn && x > rt)) mn = mx, rt = x;   }   int getsz(int x, int F) {     sz[x] = 1;     if (ls[x] && ls[x] != F && !z[ls[x]]) sz[x] += getsz(ls[x], x);     if (rs[x] && rs[x] != F && !z[rs[x]]) sz[x] += getsz(rs[x], x);     if (fa[x] && fa[x] != F && !z[fa[x]]) sz[x] += getsz(fa[x], x);     return sz[x];   }   int getleaf(int x) { return x <= n ? x : getleaf(ls[x]); }   void dfs(int x) {     z[x] = 1;     if (x <= n) {       m++;       if (ls[fa[x]] == x)         ls[fa[x]] = m;       else         rs[fa[x]] = m;       fa[m] = fa[x];       fa[x] = m;       fa[id] = m;       ls[m] = x;       rs[m] = id;       return;     }     int a1 = getleaf(ls[x]);     int a2 = getleaf(rs[x]);     printf( %d %d %d n , a1, a2, id);     fflush(stdout);     scanf( %s , s);     char ch = s[0];     if (ch ==  X ) {       if (z[fa[x]] || !fa[x]) {         m++;         if (fa[x]) {           if (ls[fa[x]] == x)             ls[fa[x]] = m;           else             rs[fa[x]] = m;           fa[m] = fa[x];         }         fa[x] = m;         fa[id] = m;         ls[m] = x;         rs[m] = id;         return;       }       Sz = getsz(fa[x], 0);       mn = 1e9;       getrt(fa[x], 0);       dfs(rt);     }     if (ch ==  Y ) {       if (z[rs[x]]) {         m++;         fa[rs[x]] = fa[id] = m;         ls[m] = rs[x];         rs[m] = id;         rs[x] = m;         fa[m] = x;         return;       }       Sz = getsz(rs[x], 0);       mn = 1e9;       getrt(rs[x], 0);       dfs(rt);     }     if (ch ==  Z ) {       if (z[ls[x]]) {         m++;         fa[ls[x]] = fa[id] = m;         ls[m] = ls[x];         rs[m] = id;         ls[x] = m;         fa[m] = x;         return;       }       Sz = getsz(ls[x], 0);       mn = 1e9;       getrt(ls[x], 0);       dfs(rt);     }   }   int main() {     scanf( %d , &n);     m = n;     m++;     ls[m] = 1;     rs[m] = 2;     fa[1] = fa[2] = m;     for (id = 3; id <= n; id++) {       memset(z, 0, sizeof(z));       Sz = 2 * id - 3;       mn = 1e9;       getrt(1, 0);       dfs(rt);     }     puts( -1 );     for (int i = 1; i <= m; i++) printf( %d  , fa[i] ? fa[i] : -1);   }
#include <bits/stdc++.h>   using namespace std;   unordered_map<int, int> parent[100005];   unordered_map<int, int> depth[100005];   unordered_map<int, int> memo[100005];   int Find(int node, int color) {     if (parent[node][color] == node) return node;     parent[node][color] = Find(parent[node][color], color);     return parent[node][color];   }   void Union(int a, int b, int color) {     if (!parent[a].count(color)) {       parent[a][color] = a;     }     if (!parent[b].count(color)) {       parent[b][color] = b;     }     int roota(Find(a, color));     int rootb(Find(b, color));     if (depth[roota][color] < depth[rootb][color]) swap(roota, rootb);     if (depth[roota][color] == depth[rootb][color]) depth[roota][color]++;     parent[rootb][color] = roota;   }   int solve(int a, int b) {     if (memo[a].count(b)) return memo[a][b];     int res(0);     if (parent[a].size() > parent[b].size()) swap(a, b);     unordered_map<int, int>::iterator it;     for (it = parent[a].begin(); it != parent[a].end(); it++) {       int color(it->first);       if (!parent[b].count(color)) continue;       if (Find(a, color) == Find(b, color)) res++;     }     memo[a][b] = memo[b][a] = res;     return res;   }   int main() {     int n, m, q;     cin >> n >> m;     for (int a, b, c, i = 0; i < m; i++) {       scanf( %d%d%d , &a, &b, &c);       a--;       b--;       Union(a, b, c);     }     cin >> q;     for (int a, b, i = 0; i < q; i++) {       scanf( %d%d , &a, &b);       a--;       b--;       printf( %d n , solve(a, b));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, z, i, y, x = 1;     string line;     cin >> n >> k >> line;     for (i = 0; i < line.length(); i++) {       if (line[i] ==  G ) {         z = i;       }       if (line[i] ==  T ) {         y = i;       }     }     if (y < z) {       k = -k;     }     if ((y - z) % k == 0) {       for (i = z; i != y; i = i + k) {         if (line[i] ==  # ) {           cout <<  NO ;           x = 0;           break;         }       }       if (x != 0) {         cout <<  YES ;       }     } else {       cout <<  NO ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, d, t[110], tot = 0;     cin >> n >> d;     for (int i = 0; i < n; i++) cin >> t[i], tot += t[i];     if (tot + (n - 1) * 10 > d)       cout << -1 << endl;     else {       cout << (n - 1) * 2 + (d - tot - (n - 1) * 10) / 5 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x, y, m, aux, rs = 0;   void neg() {     rs = (-y) / x;     rs++;     y = y + rs * x;   }   void rec() {     aux = x + y;     rs++;     if (aux < m) {       y = x;       x = aux;       rec();     }   }   int main() {     cin >> x >> y >> m;     aux = max(x, y);     y = min(x, y);     x = aux;     if (x >= m) {       cout <<  0  << endl;       return 0;     }     if (x < 1) {       cout <<  -1  << endl;       return 0;     }     if (y < 1 && x > 0) {       neg();     }     rec();     cout << rs << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int l;   int a[1000007];   int minn[1000007], maxn[1000007], cnt;   int cmp(int x, int y) { return x > y; }   int main() {     scanf( %d , &n);     long long ans = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &l);       int flag = 0;       for (int j = 1; j <= l; j++) {         scanf( %d , &a[j]);         if (j == 1) continue;         if (a[j] > a[j - 1]) flag = 1;       }       if (flag == 0) {         minn[++cnt] = a[l];         maxn[cnt] = a[1];       }     }     sort(minn + 1, minn + 1 + cnt);     for (int i = 1; i <= cnt; i++) {       int pos = lower_bound(minn + 1, minn + 1 + cnt, maxn[i]) - minn - 1;       ans += cnt - pos;     }     printf( %lld , 1ll * n * n - ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long INFF = 0x3f3f3f3f3f3f3f3fll;   const long long M = 1e9 + 7;   const long long maxn = 1e5 + 7;   const double eps = 0.00000001;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   template <typename T>   inline T abs(T a) {     return a > 0 ? a : -a;   }   int n, m;   int i, j, k;   int main() {     scanf( %d , &n);     printf( %d , (n - 1) / 2);   }
#include <bits/stdc++.h>   using namespace std;   const int MN = 200000, INF = 1100000000;   int main() {     int n;     scanf( %d , &n);     static int x1[MN], y1[MN], x2[MN], y2[MN];     for (int i = 0; i < n; i++) {       scanf( %d%d%d%d , x1 + i, y1 + i, x2 + i, y2 + i);     }     static int x1l[MN], y1l[MN], x2l[MN], y2l[MN];     x1l[0] = y1l[0] = -INF;     x2l[0] = y2l[0] = INF;     for (int i = 0; i < n; i++) {       x1l[i + 1] = max(x1l[i], x1[i]);       y1l[i + 1] = max(y1l[i], y1[i]);       x2l[i + 1] = min(x2l[i], x2[i]);       y2l[i + 1] = min(y2l[i], y2[i]);     }     static int x1r[MN], y1r[MN], x2r[MN], y2r[MN];     x1r[n] = y1r[n] = -INF;     x2r[n] = y2r[n] = INF;     for (int i = n - 1; i >= 0; i--) {       x1r[i] = max(x1r[i + 1], x1[i]);       y1r[i] = max(y1r[i + 1], y1[i]);       x2r[i] = min(x2r[i + 1], x2[i]);       y2r[i] = min(y2r[i + 1], y2[i]);     }     for (int i = 0; i < n; i++) {       int X1 = max(x1l[i], x1r[i + 1]);       int Y1 = max(y1l[i], y1r[i + 1]);       int X2 = min(x2l[i], x2r[i + 1]);       int Y2 = min(y2l[i], y2r[i + 1]);       if (X1 <= X2 && Y1 <= Y2) {         printf( %d %d n , X1, Y1);         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int d[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};   int ans, k = 0;   int egg[1000000];   int n, m, vis[1050][1050]{0}, ma[1050][1050];   void dfs(int x, int y) {     for (int i = 0; i < 4; i++) {       int xx = x + d[i][0];       int yy = y + d[i][1];       if ((ma[x][y] >> i) % 2 == 0 && vis[xx][yy] == 0) {         vis[xx][yy] = 1;         dfs(xx, yy);         ans++;       }     }   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> ma[i][j];       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (!vis[i][j]) {           ans = 1;           vis[i][j] = 1;           dfs(i, j);           egg[++k] = ans;         }       }     }     sort(egg + 1, egg + k + 1);     for (int i = k; i >= 1; i--) {       cout << egg[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> f, num;   int Q;   int find(int x) {     if (!f.count(x)) return x;     int fa = find(f[x]);     num[x] ^= num[f[x]];     return f[x] = fa;   }   int main() {     scanf( %d , &Q);     int last = 0;     while (Q--) {       int opt, l, r, x;       scanf( %d %d %d , &opt, &l, &r);       l ^= last, r ^= last;       if (l > r) swap(l, r);       l--;       if (opt & 1) {         scanf( %d , &x);         x ^= last;         int fl = find(l), fr = find(r);         if (fl != fr) f[fr] = fl, num[fr] = x ^ num[l] ^ num[r];       } else {         int fl = find(l), fr = find(r);         if (fl != fr)           last = 1, printf( -1 n );         else           last = num[l] ^ num[r], printf( %d n , last);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int j, i, t, e, n;     cin >> t;     while (t--) {       cin >> n;       string s;       cin >> s;       string a, b;       a = s;       b = s;       bool f = 0;       a[0] =  1 ;       b[0] =  1 ;       i = 1;       while (s[i] !=  1  && i < n) {         if (s[i] ==  0 ) {           a[i] =  0 ;           b[i] =  0 ;         } else {           a[i] =  1 ;           b[i] =  1 ;         }         i++;       }       if (s[i] ==  1 ) {         a[i] =  1 ;         b[i] =  0 ;       }       i++;       while (i < n) {         if (s[i] ==  0 ) {           a[i] =  0 ;           b[i] =  0 ;         } else if (s[i] ==  2 ) {           a[i] =  0 ;           b[i] =  2 ;         } else {           b[i] =  1 ;           a[i] =  0 ;         }         i++;       }       cout << a << endl << b << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   void solve() {     int n;     cin >> n;     int ar[n], lock[n];     for (int i = 0; i < n; i++) cin >> ar[i];     vector<int> temp, res;     bool flag = false;     for (int i = 0; i < n - 1; i++) {       if (ar[i] > ar[i + 1]) {         flag = true;       }     }     if (flag == false) {       cout <<  YES  << endl;       return;     }     int minn = *min_element(ar, ar + n);     for (int i = 0; i < n; i++) {       if (ar[i] % minn == 0) {         temp.push_back(ar[i]);       }     }     sort(temp.begin(), temp.end());     int j = 0;     for (int i = 0; i < n; i++) {       if (ar[i] % minn != 0) {         res.push_back(ar[i]);       } else         res.push_back(temp[j++]);     }     for (int i = 0; i < n - 1; i++) {       if (res[i] > res[i + 1]) {         cout <<  NO  << endl;         return;       }     }     cout <<  YES  << endl;   }   int main() {     int T;     cin >> T;     while (T--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   using i64 = long long int;   using ii = pair<int, int>;   using ii64 = pair<i64, i64>;   int main() {     int n;     scanf( %d , &n);     string s;     cin >> s;     int maxPhone = n / 11;     int eight = 0;     for (auto& c : s)       if (c ==  8 ) eight++;     printf( %d n , min(maxPhone, eight));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 2;   int num[N], n, res[N], a[N];   void ReadData() {     cin >> n;     for (int i = 0; i < n; ++i) cin >> num[i];   }   void Update(int x, int y) {     if (x > y) return;     ++a[x];     --a[y + 1];   }   void Solve() {     for (int i = 0; i < n; ++i) {       int k = 1;       for (; k * k <= (i - 1); ++k)         if (num[i] < num[(i - 1) / k]) ++res[k];       for (int j = 0; j <= (i - 1) / k; ++j)         if (num[i] < num[j]) {           if (0 == j)             Update(i, n - 1);           else             Update(max(k, (i - 1) / (j + 1) + 1), (i - 1) / j);         }     }     for (int i = 1; i < n; ++i) {       a[i] += a[i - 1];       res[i] += a[i];     }   }   void Output() {     for (int i = 1; i < n; ++i) cout << res[i] << endl;   }   int main() {     ReadData();     Solve();     Output();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[5][5], sum, add, ex;   char c[5][5];   int main() {     for (int i = 1; i <= 4; i++)       for (int j = 1; j <= 4; j++) {         cin >> c[i][j];         if (c[i][j] ==  x ) {           a[i][j] = 4;           sum++;         } else if (c[i][j] ==  o ) {           a[i][j] = 1;           add++;         }       }     if (sum == add)       ex = 8;     else       ex = 2;     for (int i = 1; i <= 4; i++)       for (int j = 1; j <= 2; j++)         if (a[i][j] + a[i][j + 1] + a[i][j + 2] == ex) {           cout <<  YES ;           return 0;         }     for (int i = 1; i <= 2; i++)       for (int j = 1; j <= 4; j++)         if (a[i][j] + a[i + 1][j] + a[i + 2][j] == ex) {           cout <<  YES ;           return 0;         }     if (a[1][1] + a[2][2] + a[3][3] == ex) {       cout <<  YES ;       return 0;     }     if (a[2][2] + a[3][3] + a[4][4] == ex) {       cout <<  YES ;       return 0;     }     if (a[1][4] + a[2][3] + a[3][2] == ex) {       cout <<  YES ;       return 0;     }     if (a[2][3] + a[3][2] + a[4][1] == ex) {       cout <<  YES ;       return 0;     }     if (a[3][1] + a[2][2] + a[1][3] == ex) {       cout <<  YES ;       return 0;     }     if (a[4][2] + a[3][3] + a[2][4] == ex) {       cout <<  YES ;       return 0;     }     if (a[2][1] + a[3][2] + a[4][3] == ex) {       cout <<  YES ;       return 0;     }     if (a[1][2] + a[2][3] + a[3][4] == ex) {       cout <<  YES ;       return 0;     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp(int a, int b) {     if ((a == 1 && b == 1) || b == 0) return 0;     return dp(max(b + 1, a - 2), min(b + 1, a - 2)) + 1;   }   int main() {     int n, m;     cin >> n >> m;     printf( %d , dp(max(n, m), min(n, m)));   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T, d;     scanf( %d , &T);     while (T--) {       scanf( %d , &d);       double a = 0, b = 0;       double x = d * d - 4 * d;       if (x < 0) {         printf( N n );         continue;       } else {         a = (d - sqrt(x)) / 2.0;         b = d - a;         if (a < b) swap(a, b);         printf( Y %.9lf %.9lf n , a, b);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i = 0;     string str;     scanf( %d , &n);     cin >> str;     if (n % 2 == 0) {       i = 2;       printf( %c%c , str[0], str[1]);     } else {       i = 3;       printf( %c%c%c , str[0], str[1], str[2]);     }     for (; i < n; i += 2) {       printf( -%c%c , str[i], str[i + 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > grafo[212345];   int marc[212345], dp[212345], ans[212345], ansmin = 1e9;   void dfs(int x) {     marc[x] = 1;     for (int i = 0; i < grafo[x].size(); i++) {       int viz = grafo[x][i].first;       int type = grafo[x][i].second;       if (marc[viz]) continue;       dfs(viz);       dp[x] += dp[viz];       if (type) dp[x]++;     }   }   void dfs2(int x) {     marc[x] = 0;     ans[x] = dp[x];     ansmin = min(ansmin, ans[x]);     for (int i = 0; i < grafo[x].size(); i++) {       int viz = grafo[x][i].first;       int type = grafo[x][i].second;       if (!marc[viz]) continue;       int dpx = dp[x];       int dpv = dp[viz];       dp[x] -= dp[viz];       if (type) dp[x]--;       dp[viz] += dp[x];       if (!type) dp[viz]++;       dfs2(viz);       dp[x] = dpx;       dp[viz] = dpv;     }   }   int n;   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d %d , &u, &v);       grafo[u].push_back(make_pair(v, 0));       grafo[v].push_back(make_pair(u, 1));     }     dfs(1);     dfs2(1);     printf( %d n , ansmin);     for (int i = 1; i <= n; i++) {       if (ansmin == ans[i]) printf( %d  , i);     }     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int n, m, i, j, k, a[N], u, v, q, x;   vector<int> b[N];   long long ans;   long long f(int x) { return 1LL * b[x].size() * (a[x] - b[x].size()); }   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= m; i++) {       scanf( %d%d , &u, &v);       if (u > v) swap(u, v);       b[u].push_back(v);       a[u]++;       a[v]++;     }     scanf( %d , &q);     for (i = 1; i <= n; i++) ans += f(i);     printf( %lld n , ans);     for (j = 1; j <= q; j++) {       scanf( %d , &x);       ans -= f(x);       for (i = 0; i < b[x].size(); i++)         ans -= f(b[x][i]), b[b[x][i]].push_back(x), ans += f(b[x][i]);       b[x].clear();       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 9;   int n;   int fs[maxn];   int pj[maxn];   long long ansji, ansou;   void solve() {     int i;     for (i = 1; i <= n; ++i) fs[i] += fs[i - 1];     for (i = 1; i <= n; ++i) {       pj[i] = pj[i - 1] + (fs[i] & 1);     }     for (i = 1; i <= n; ++i) {       if (fs[i] & 1) {         ansji += i - pj[i - 1];         ansou += pj[i - 1];       } else {         ansji += pj[i - 1];         ansou += i - pj[i - 1];       }     }   }   void _solve() {     solve();     cout << ansji <<     << ansou << endl;   }   void _prepare() {     cin >> n;     for (int i = 1; i <= n; ++i) {       int x;       cin >> x;       fs[i] = x < 0;     }   }   int _main_prog() {     _prepare();     _solve();     return 0;   }   int main() { return _main_prog(); }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int i, m, n;     double add, ans, t1, t2;     scanf( %ld%ld , &m, &n);     for (i = 1; i <= m; i++) {       t1 = (double)i / m;       t2 = (double)(i - 1) / m;       add = i * (pow(t1, n) - pow(t2, n));       ans += add;     }     printf( %.7lf , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[110], n = 0, res[1010], ch = 0, k = 0;   string s;   int main() {     cin >> s;     memset(a, 0, sizeof a);     memset(res, 0, sizeof res);     for (int i = 0; i < (int)s.length(); ++i)       if (s[i] !=  , ) {         a[n] *= 10;         a[n] += (int)(s[i] -  0 );       } else         ++n;     ++n;     for (int i = 0; i < n; ++i) res[a[i]] = 1;     for (int i = 0; i < 1010; ++i) {       if (res[i] == 1)         ++ch;       else {         if (k > 0 && ch) cout <<  , ;         if (ch && k == 0) ++k;         if (ch == 1)           cout << i - 1;         else if (ch)           cout << i - ch <<  -  << i - 1;         ch = 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long sz = 10000001;   bool vis[sz];   int cs[sz], a[sz], n, m;   void run() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   int main() {     run();     cin >> n;     int x;     for (int i = 0; i < n; i++) {       cin >> x;       a[x]++;     }     for (int i = 2; i < sz; i++)       if (!vis[i])         for (int j = i; j < sz; j += i) {           vis[j] = 1;           if (a[j]) cs[i] += a[j];         }     for (int i = 3; i < sz; i++) cs[i] = cs[i] + cs[i - 1];     cin >> m;     while (m--) {       long long l, r;       cin >> l >> r;       r = min(r, sz - 1);       l = min(l, sz - 1);       cout << cs[r] - cs[l - 1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100;   char ch[maxn][maxn];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i <= n + 1; i++) {       for (int j = 0; j <= n + 1; j++) {         ch[i][j] =  # ;       }     }     for (int i = 1; i <= n; i++) {       getchar();       for (int j = 1; j <= n; j++) {         scanf( %c , &ch[i][j]);       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (ch[i][j] ==  # ) {           continue;         }         if (ch[i - 1][j] ==  # ) {           continue;         }         if (ch[i][j - 1] ==  # ) {           continue;         }         if (ch[i + 1][j] ==  # ) {           continue;         }         if (ch[i][j + 1] ==  # ) {           continue;         }         ch[i][j] =  # ;         ch[i][j + 1] =  # ;         ch[i][j - 1] =  # ;         ch[i + 1][j] =  # ;         ch[i - 1][j] =  # ;       }     }     bool ans = true;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (ch[i][j] ==  . ) {           ans = false;         }       }     }     if (ans) {       printf( YES n );     } else {       printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int ma = -1, mi = 1000000000000000;   inline long long int gcd(long long int a, long long int b) {     return b ? gcd(b, a % b) : a;   }   inline long long int lcm(long long int a, long long int b, long long int MOD) {     return a / gcd(a, b) * b % MOD;   }   long long int power(long long int x, unsigned int y) {     if (y == 0)       return 1;     else if (y % 2 == 0)       return power(x, y / 2) * power(x, y / 2);     else       return x * power(x, y / 2) * power(x, y / 2);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long int n, i, j = 1, k = 0, b;     cin >> n >> k;     if (k % 2 == 1) {       cout << 1 << endl;       return 0;     }     while (true) {       if (k % 2 == 1) break;       j++;       k /= 2;     }     cout << j << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int var;     scanf( %ld , &var);     if (var >= 0)       cout << var;     else {       int a, b;       a = var % 10;       var /= 10;       b = var % 10;       var /= 10;       if (a > b)         var = var * 10 + a;       else         var = var * 10 + b;       cout << var;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > v;   int n, r, m;   bool cmp(const pair<int, int>& a, const pair<int, int>& b) {     return a.first * a.first + a.second * a.second >            b.first * b.first + b.second * b.second;   }   inline int get_dis(const int& first, const int& second) {     return first * first + second * second;   }   void init() {     v.clear();     for (int i = -r; i <= r; ++i)       for (int j = -r; j <= r; ++j)         if (i * i + j * j <= r * r) v.push_back(make_pair(i, j));     sort(v.begin(), v.end(), cmp);     m = min((int)v.size(), 30 - n * 2);   }   int b[120], ans[120], ansdist;   int dist[39][39];   void dfs(int first, int last, int sum) {     if (first == n) {       if (sum > ansdist) {         for (int i = 0; i < n; ++i) ans[i] = b[i];         ansdist = sum;       }       return;     }     int ndist;     for (int i = last; i < m; ++i) {       ndist = 0;       for (int j = 0; j < first; ++j) ndist += dist[i][b[j]];       b[first] = i;       dfs(first + 1, i, sum + ndist);     }   }   void solve() {     for (int i = 0; i < m; ++i)       for (int j = 0; j < m; ++j)         dist[i][j] = get_dis(v[i].first - v[j].first, v[i].second - v[j].second);     ansdist = 0;     dfs(0, 0, 0);     printf( %d n , ansdist);     for (int i = 0; i < n; ++i)       printf( %d %d n , v[ans[i]].first, v[ans[i]].second);   }   int main() {     while (scanf( %d%d , &n, &r) != EOF) {       init();       solve();     }     return 0;   }