malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = 2147483647;   const long long LLINF = 9223372036854775807LL;   const int ST = 100010;   const int ST1 = 1000010;   const long long MOD = 1000000007;   long long ABS(long long a) {     if (a < 0)       return a * (-1);     else       return a;   }   int mas[30];   bool ans = true;   void bad() {     cout <<  NO ;     exit(0);   }   vector<vector<int> > ppp;   int sz = 0;   void per(vector<int> &t) {     if ((int)((t).size()) == sz) {       ppp.push_back(t);     } else {       t.push_back(0);       per(t);       t.pop_back();       t.push_back(1);       per(t);       t.pop_back();     }   }   void per(vector<int> val, int ed, vector<int> zap) {     if ((int)((val).size()) == 0) {       if (ed == 0) {         cout <<  YES ;         exit(0);       } else         return;     }     vector<vector<int> > pp;     vector<int> em;     sz = (int)((zap).size());     ppp.clear();     per(em);     pp = ppp;     int tek = val[(int)((val).size()) - 1] - 1;     val.pop_back();     int ost = 0;     for (int i = 0; i < (int)((pp).size()); i++) {       vector<int> next;       next.push_back(tek + 1);       ost = 0;       int kk = 0;       for (int j = 0; j < (int)((pp[i]).size()); j++) {         if (pp[i][j] == 1) {           ost += zap[j];           kk++;         } else           next.push_back(zap[j]);       }       if (ost <= tek) {         int s = tek - ost;         if (s > ed) continue;         kk += s;         if (kk == 1) continue;         per(val, ed - s, next);       }     }   }   int main() {     int n;     cin >> n;     if (n == 1) {       cout <<  YES ;       return 0;     }     int kk = 0;     for (int i = 0; i < n; i++) {       cin >> mas[i];       if (mas[i] == 2) bad();       if (mas[i] == 1) kk++;     }     sort(mas, mas + n);     int mn = n / 2;     if (kk < mn) bad();     vector<int> t;     int nol = 0;     for (int i = 0; i < n; i++)       if (mas[i] != 1)         t.push_back(mas[i]);       else         nol++;     vector<int> em;     reverse(t.begin(), t.end());     per(t, nol, em);     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, j, k, p = 1000000007;   int A[10], B[10];   int main() {     cin >> n;     A[0] = 1;     for (i = 1; i <= n; i++) {       for (j = 0; j <= 3; j++)         for (k = 0; k <= 3; k++) {           if (j == k) continue;           B[j] = (B[j] + A[k]) % p;         }       for (j = 0; j <= 3; j++) {         A[j] = B[j];         B[j] = 0;       }     }     cout << A[0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   const long long mod = 998244353;   const double pi = acos(-1);   long long fastpow(long long b, long long e) {     if (!e) return 1;     long long ret = fastpow(b, e / 2);     ret = (ret * ret) % mod;     if (e % 2) ret = (ret * b) % mod;     return ret;   }   long long modinv(long long x) { return fastpow(x, mod - 2); }   double torad(double ang) { return ang * pi / 180.0; }   int k, n, m;   string s[15][15];   bool valid(int x, int y, int z) {     if (x >= k || y >= n || z >= m || x < 0 || y < 0 || z < 0) return 0;     return 1;   }   void dfs(int x, int y, int z) {     if (!valid(x, y, z)) return;     if (s[x][y][z] ==  $  || s[x][y][z] ==  # ) return;     s[x][y][z] =  $ ;     dfs(x + 1, y, z);     dfs(x - 1, y, z);     dfs(x, y + 1, z);     dfs(x, y - 1, z);     dfs(x, y, z + 1);     dfs(x, y, z - 1);   }   int main() {     scanf( %d%d%d , &k, &n, &m);     for (int i = 0; i < k; i++) {       for (int j = 0; j < n; j++) cin >> s[i][j];     }     int x, y;     scanf( %d%d , &x, &y);     dfs(0, x - 1, y - 1);     int cntr = 0;     for (int i = 0; i < k; i++) {       for (int j = 0; j < n; j++) {         for (int l = 0; l < m; l++) {           if (s[i][j][l] ==  $ ) cntr++;         }       }     }     printf( %d , cntr);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   int q, num;   vector<int> v[maxn];   bool vis[maxn];   void dfs(int x) {     for (int i = 0; i < v[x].size(); i++) {       if (!vis[v[x][i]]) {         num++;         vis[v[x][i]] = 1;         dfs(v[x][i]);       }     }   }   int main() {     ios::sync_with_stdio(false);     cin >> q;     while (q--) {       int n, m, a, b;       long long ans;       cin >> n >> m >> a >> b;       for (int i = 1; i <= n; i++) {         v[i].clear();         vis[i] = 0;       }       for (int i = 1; i <= m; i++) {         int x, y;         cin >> x >> y;         v[x].push_back(y);         v[y].push_back(x);       }       vis[b] = vis[a] = 1, num = 0;       dfs(a);       ans = n - 2 - num;       fill(vis + 1, vis + 1 + n, 0);       vis[b] = vis[a] = 1, num = 0;       dfs(b);       ans *= (n - 2) - num;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fastInOut() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   const int size = 300000 + 5;   void solve() {     long long n;     cin >> n;     long long ans = 0;     long long x = 1;     long long ctr = 0;     long long till_now = 0;     while (till_now < n) {       ans++;       till_now += (x * (x + 1) / 2);       ctr++;       x += (1 << ctr);     }     if (till_now > n) ans--;     cout << ans << endl;   }   int main(int argc, char const* argv[]) {     fastInOut();     int t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100100;   int n;   vector<pair<int, int>> a;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       int x, y;       scanf( %d%d , &x, &y);       a.emplace_back(x, 1);       a.emplace_back(y + 1, -1);     }     sort(a.begin(), a.end());     int k = 0;     for (auto p : a) {       k += p.second;       if (k > 2) {         puts( NO );         return 0;       }     }     puts( YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, t;   int a[10010];   map<int, int> calc;   int wow;   int LIS() {     int len = 0;     int d[10010];     d[len] = -0x7fffffff;     for (int i = 1; i <= wow; i++) {       if (d[len] <= a[i])         d[++len] = a[i];       else {         int mid = upper_bound(d + 1, d + 1 + len, a[i]) - d;         d[mid] = a[i];       }     }     return len;   }   int main() {     cin >> n >> t;     for (int i = 1; i <= n; i++) cin >> a[i];     if (t < n) {       for (int i = 1; i < t; i++)         for (int j = 1; j <= n; j++) a[i * n + j] = a[j];       wow = n * t;       cout << LIS();     } else {       for (int i = 1; i < n; i++)         for (int j = 1; j <= n; j++) a[i * n + j] = a[j];       wow = n * n;       int sth = LIS();       int maxi = 0, num;       for (int i = 1; i <= n; i++) calc[a[i]]++;       for (map<int, int>::iterator i = calc.begin(); i != calc.end(); i++)         maxi = max(maxi, i->second);       cout << sth + maxi * (t - n);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2010;   int N, M;   char A[MAXN][MAXN];   int cnt[MAXN];   int main() {     scanf( %d %d , &N, &M);     for (int i = 0; i < N; i++) {       scanf( %s , A[i]);       for (int j = 0; j < M; j++) {         if (A[i][j] ==  1 ) {           cnt[j]++;         }       }     }     for (int i = 0; i < N; i++) {       bool need = false;       for (int j = 0; j < M; j++) {         if (A[i][j] ==  1  && cnt[j] == 1) {           need = true;           break;         }       }       if (!need) {         puts( YES );         return 0;       }     }     puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double a, d;     int n;     cin >> a >> d >> n;     for (int i = 0; i < n; i++) {       double temp = fmod((i + 1) * d, 4 * a);       if (temp < a)         printf( %.9f %.9f n , temp, 0.0);       else if (temp < a * 2)         printf( %.9f %.9f n , a, temp - a);       else if (temp < a * 3)         printf( %.9f %.9f n , 3 * a - temp, a);       else         printf( %.9f %.9f n , 0.0, 4 * a - temp);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1000002], b[4000000], intialsum[1000003];   int q(int ind) {     int sum = 0;     while (ind > 0) {       sum += b[ind];       ind -= ind & (-ind);     }     return sum;   }   void u(int ind, int n, int val) {     while (ind <= n) {       b[ind] += val;       ind += ind & (-ind);     }   }   int main() {     {       ios_base::sync_with_stdio(false);       cin.tie(0);     };     int i, j, k, l, n, m, t, h;     cin >> n >> k;     for (i = 1; i <= n; i++) {       cin >> j;       a[j]++;     }     for (i = 1; i <= n; i++) intialsum[i] = intialsum[i - 1] + a[i];     for (i = 1; i <= k; i++) {       cin >> j;       if (j > 0) {         a[j]++;         u(j, n, 1);       } else {         l = 1;         h = n;         while (h > l) {           m = (l + h) >> 1;           if (intialsum[m] + q(m) >= -j)             h = m;           else             l = m + 1;         }         a[l]--;         u(l, n, -1);       }     }     for (i = 1; i <= n; i++)       if (a[i] > 0) return cout << i << endl, 0;     cout << 0 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1000005;   long long res[MAX], a[MAX], b[MAX];   void add(int l, int r, int x, int y) {     a[l] += x;     a[r] -= x + y * (r - l);     b[l] += y;     b[r] -= y;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     for (int from = 0; from < n; from++) {       int to;       cin >> to;       to--;       if (from <= to) {         add(0, to - from + 1, to - from, -1);         add(to - from + 1, n - from, 1, 1);         add(n - from, n, to, -1);       } else {         add(0, n - from, from - to, 1);         add(n - from, n - from + to + 1, to, -1);         add(n - from + to + 1, n, 1, 1);       }     }     long long val = 0, step = 0;     for (int i = 0; i < n; i++) {       val += a[i];       step += b[i];       res[i] = val;       val += step;     }     int mn = min_element(res, res + n) - res;     cout << res[mn] <<     << mn <<   n ;     return 0;   }
#include <bits/stdc++.h>   const double eps = 1e-9;   const int MOD = int(1e9) + 7;   const int MaxN = int(2e5) + 256;   using namespace std;   int n, a, b;   int main() {     cin >> n >> a >> b;     if (n > a * b) {       cout << -1;       return 0;     }     int cnt = 1;     bool ok = true, r = true;     for (int i = 1; i <= a; i++) {       if (r) {         for (int j = 1; j <= b; j++) {           if (cnt <= n)             cout << cnt++ <<    ;           else             cout << 0 <<    ;         }         r = false;       } else {         cnt += b - 1;         for (int j = 1; j <= b; j++) {           if (cnt <= n)             cout << cnt <<    ;           else             cout << 0 <<    ;           cnt--;         }         cnt += b + 1;         r = true;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long qpow(long long a, long long b, long long m) {     long long r = 1;     a %= m;     for (; b; b >>= 1) {       if (b & 1) r = r * a % m;       a = a * a % m;     }     return r;   }   const int inf = 0x7fffffff;   const int maxn = 2e5 + 10;   vector<pair<int, int> > g[maxn];   vector<int> ans;   set<pair<int, int> > s;   int n, k;   int main() {     ios::sync_with_stdio(false);     cin >> n >> k;     for (int i = 1; i <= n; i++) {       int l, r;       cin >> l >> r;       g[l].push_back(pair<int, int>(r, i));     }     for (int i = 1; i <= 200000; i++) {       for (int j = 0; j < (int)(g[i]).size(); j++) s.insert(g[i][j]);       while ((int)(s).size() > k) {         set<pair<int, int> >::iterator it = s.end();         it--;         ans.push_back(it->second);         s.erase(it);       }       while (!s.empty() && (s.begin()->first) <= i) s.erase(s.begin());     }     cout << (int)(ans).size() << endl;     for (int i = 0; i < (int)(ans).size(); i++) {       if (i) cout <<    ;       cout << ans[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int sz = 1e5 + 5;   vector<tuple<int, int, int> > q;   vector<int> FWT[sz];   int mt[sz];   vector<int> mapt[sz];   void update(int idx, int v, int pn) {     vector<int>& x = FWT[v];     while (idx < x.size()) {       x[idx] += pn;       idx = idx + (idx & -idx);     }   }   int query(int idx, int v) {     vector<int>& x = FWT[v];     int ans = 0;     while (idx > 0) {       ans += x[idx];       idx = idx - (idx & -idx);     }     return ans;   }   int main() {     int n;     cin >> n;     map<int, int> values;     int vv = 1;     for (int i = 0; i < n; ++i) {       tuple<int, int, int> x;       cin >> get<0>(x) >> get<1>(x) >> get<2>(x);       if (values[get<2>(x)] == 0) {         values[get<2>(x)] = vv++;       }       get<2>(x) = values[get<2>(x)];       q.push_back(x);       mapt[get<2>(x)].push_back(get<1>(x));     }     for (int i = 1; i < vv; ++i) {       sort(mapt[i].begin(), mapt[i].end());       FWT[i].resize(unique(mapt[i].begin(), mapt[i].end()) - mapt[i].begin() + 2);     }     for (int i = 0; i < n; ++i) {       int a = get<0>(q[i]);       int t = get<1>(q[i]);       int x = get<2>(q[i]);       t = lower_bound(mapt[x].begin(), mapt[x].end(), t) - mapt[x].begin() + 1;       if (a == 1) {         update(t, x, 1);       } else if (a == 2) {         update(t, x, -1);       } else {         cout << query(t, x) << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 20;   int t;   int n, s;   string str;   char n1[N];   char n2[N];   int a[N], b[N], c[N];   int main() {     cin >> t;     while (t--) {       cin >> str >> s;       int sum = 0, k = -1, pos = -1, flag = 1;       for (int i = 0; i < str.size(); i++) {         sum += str[i] -  0 ;         if (sum == s && flag)           pos = i, flag = 0;         else if (sum > s) {           if (pos != -1)             k = pos;           else             k = i;           break;         }       }       if (sum <= s || (pos != -1 && k == -1)) {         cout << 0 << endl;         continue;       }       memset(c, 0, sizeof c);       memset(n2, 0, sizeof n2);       memset(n1, 0, sizeof n1);       memset(a, 0, sizeof a);       memset(b, 0, sizeof b);       for (int i = k; i < str.size(); i++) n2[i - k] = str[i];       n1[0] =  1 ;       for (int i = 1; i <= strlen(n2); i++) n1[i] =  0 ;       int lena = strlen(n1);       int lenb = strlen(n2);       for (int i = 0; i <= lena - 1; i++) a[lena - i] = int(n1[i] -  0 );       for (int i = 0; i <= lenb - 1; i++) b[lenb - i] = int(n2[i] -  0 );       int i = 1;       while (i <= lena || i <= lenb) {         if (a[i] < b[i]) {           a[i] += 10;           a[i + 1]--;         }         c[i] = a[i] - b[i];         i++;       }       int lenc = i;       while ((c[lenc] == 0) && (lenc > 1)) lenc--;       for (i = lenc; i >= 1; i--) cout << c[i];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> w, ww;   set<int> second[222222];   int h, m, n, x, u, uu, e, A[311111], B[311111], g, vv[222222], os[222222],       oo[222222], fl[222222];   vector<int> v[211111], s[211111];   char o;   long long ans;   int main() {     scanf( %d%d%d n , &h, &m, &n);     for (int i = 0; i < h; i++)       if (!A[i]) {         x = i;         A[i] = ++e;         B[i] = 0;         v[e].push_back(i);         x = (x + m) % h;         while (x != i) {           B[x] = v[e].size();           v[e].push_back(x);           A[x] = e;           x = (x + m) % h;         }       }     for (int i = 1; i <= e; i++)       for (int j = 0; j < v[i].size(); j++) second[i].insert(j);     for (int i = 0; i < n; i++) {       scanf( %c , &o);       if (o ==  - ) {         scanf( %d n , &x);         second[w[x]].insert(ww[x]);       } else {         scanf( %d%d n , &x, &g);         u = A[g];         uu = B[g];         if (second[u].lower_bound(uu) == second[u].end())           ans += v[u].size() - uu, uu = 0;         int z = *second[u].lower_bound(uu);         second[u].erase(z);         ans += z - uu;         w[x] = u;         ww[x] = z;       }     }     cout << (ans) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 101;   int n, m;   string s[MAXN];   int cnt[27];   bool toDel[MAXN][MAXN];   string solve() {     for (int i = 0; i < n; i++) {       memset(cnt, 0, sizeof(cnt));       for (int j = 0; j < m; j++) cnt[s[i][j] -  a ]++;       for (int j = 0; j < m; j++)         if (cnt[s[i][j] -  a ] > 1) toDel[i][j] = true;     }     for (int i = 0; i < m; i++) {       memset(cnt, 0, sizeof(cnt));       for (int j = 0; j < n; j++) cnt[s[j][i] -  a ]++;       for (int j = 0; j < n; j++)         if (cnt[s[j][i] -  a ] > 1) toDel[j][i] = true;     }     string ans =   ;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (not toDel[i][j]) ans += s[i][j];     return ans;   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) {       cin >> s[i];     }     cout << solve() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[755];   long long dp[755][755];   int n, m;   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> a[i];     dp[n + 1][0] = 0;     for (int i = n; i >= 1; i--) {       for (int j = 0; j <= n; j++) {         dp[i][j] = min(dp[i + 1][j] + a[i], (long long)0);         if (j > 0) dp[i][j] = max(dp[i][j], dp[i + 1][j - 1]);       }     }     while (m--) {       long long x;       cin >> x;       cout << lower_bound(dp[1], dp[1] + n + 1, -x) - dp[1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace fft {   const int mod = 7340033;   const int root = 5;   const int root_1 = 4404020;   const int root_pw = 1 << 20;   template <class T>   T eea(T a, T b, T& x, T& y) {     if (!b) {       x = 1;       y = 0;       return a;     }     T x1, y1;     T g = eea(b, a % b, x1, y1);     x = y1;     y = x1 - (a / b) * y1;     return g;   }   int inverse(int n) {     int x, y;     eea(n, mod, x, y);     x %= mod;     if (x < 0) x += mod;     return x;   }   void fft(vector<int>& a, bool invert) {     int n = a.size();     for (int i = 1, j = 0; i < n; i++) {       int bit = n >> 1;       for (; j & bit; bit >>= 1) j ^= bit;       j ^= bit;       if (i < j) swap(a[i], a[j]);     }     for (int len = 2; len <= n; len <<= 1) {       int wlen = invert ? root_1 : root;       for (int i = len; i < root_pw; i <<= 1) wlen = 1LL * wlen * wlen % mod;       for (int i = 0; i < n; i += len) {         int w = 1;         for (int j = 0; j < len / 2; j++) {           int u = a[i + j], v = (int)(1LL * a[i + j + len / 2] * w % mod);           a[i + j] = u + v < mod ? u + v : u + v - mod;           a[i + j + len / 2] = u - v >= 0 ? u - v : u - v + mod;           w = 1LL * w * wlen % mod;         }       }     }     if (invert) {       int n_1 = inverse(n);       for (int& x : a) x = 1LL * x * n_1 % mod;     }   }   }  // namespace fft   int order(int n) {     int z = 0;     while (n % 2 == 1 && n > 1) {       n >>= 1;       z++;     }     return z;   }   vector<int> p[32];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cerr.tie(nullptr);     p[0] = p[1] = vector<int>(4096, 0);     p[0][0] = 1;     p[1][0] = p[1][1] = 1;     for (int i = 2; i < 32; i++) {       vector<int> q = p[i - 1];       fft::fft(q, false);       for (int i = 0; i < 4096; i++) {         q[i] = q[i] * 1ll * q[i] % fft::mod;         q[i] = q[i] * 1ll * q[i] % fft::mod;       }       fft::fft(q, true);       fill(q.begin() + 1005, q.end(), 0);       rotate(q.begin(), q.begin() + 1004, q.begin() + 1005);       q[0] = 1;       swap(p[i], q);     }     int q;     cin >> q;     while (q--) {       int n, k;       cin >> n >> k;       cout << p[order(n)][k] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 111, inf = 1111111111;   int n, m, q, ans[max_n][max_n];   pair<int, int> a[max_n][max_n];   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         a[i][j] = make_pair(i, j);       }     }     while (q--) {       int tp;       scanf( %d , &tp);       if (tp <= 2) {         int x;         scanf( %d , &x);         --x;         if (tp == 1) {           pair<int, int> k = a[x][0];           for (int i = 0; i + 1 < m; ++i) {             a[x][i] = a[x][i + 1];           }           a[x][m - 1] = k;         } else {           pair<int, int> k = a[0][x];           for (int i = 0; i + 1 < n; ++i) {             a[i][x] = a[i + 1][x];           }           a[n - 1][x] = k;         }       } else {         int x, y, q;         scanf( %d%d%d , &x, &y, &q);         --x;         --y;         ans[a[x][y].first][a[x][y].second] = q;       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         printf( %d  , ans[i][j]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   char s[100005];   int main() {     int i, n, cnt1, cnt2, ans1, ans2;     cnt1 = cnt2 = ans1 = ans2 = 0;     scanf( %d%s , &n, s);     for (i = 0; i < n; i++) {       if (i & 1) {         if (s[i] ==  r ) cnt1++;       } else {         if (s[i] ==  b ) cnt2++;       }     }     ans1 = max(cnt1, cnt2);     cnt1 = cnt2 = 0;     for (i = 0; i < n; i++) {       if (i & 1) {         if (s[i] ==  b ) cnt1++;       } else {         if (s[i] ==  r ) cnt2++;       }     }     ans2 = max(cnt1, cnt2);     printf( %d , min(ans1, ans2));   }
#include <bits/stdc++.h>   using namespace std;   int n, m, data[510];   double ans;   int main() {     scanf( %d%d , &n, &m);     if (m == 0) {       printf( %.9lf n , 0);       return 0;     }     for (int i = 1; i <= n; i++) scanf( %d , &data[i]);     for (int i = 1, x, y, z; i <= m; i++) {       scanf( %d%d%d , &x, &y, &z);       ans = max(ans, (double)(data[x] + data[y]) / z);     }     printf( %.9lf , ans);   }
#include <bits/stdc++.h>   using namespace std;   int a[1000006], BLOCK;   long long ans[200005], answer = 0;   int asdf[1000006];   struct Node {     int L, R, ind;   } q[200005];   bool cmp(Node x, Node y) {     if (x.L / BLOCK != y.L / BLOCK)       return x.L / BLOCK < y.L / BLOCK;     else       return x.R < y.R;   }   void add(int pos) {     answer -= 1ll * asdf[a[pos]] * asdf[a[pos]] * a[pos];     asdf[a[pos]]++;     answer += 1ll * asdf[a[pos]] * asdf[a[pos]] * a[pos];   }   void remove(int pos) {     answer -= 1ll * asdf[a[pos]] * asdf[a[pos]] * a[pos];     asdf[a[pos]]--;     answer += 1ll * asdf[a[pos]] * asdf[a[pos]] * a[pos];   }   int main() {     int n, t;     cin >> n >> t;     BLOCK = sqrt(n);     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= t; i++) {       q[i].ind = i;       cin >> q[i].L >> q[i].R;     }     sort(q + 1, q + t + 1, cmp);     int curL = 0, curR = 0;     for (int i = 1; i <= t; i++) {       while (curL < q[i].L) {         remove(curL);         curL++;       }       while (curL > q[i].L) {         add(curL - 1);         curL--;       }       while (curR > q[i].R + 1) {         remove(curR - 1);         curR--;       }       while (curR <= q[i].R) {         add(curR);         curR++;       }       ans[q[i].ind] = answer;     }     for (int i = 1; i <= t; i++) cout << ans[i] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long isPalindrome(string str) {     long long l = 0;     long long h = str.length() - 1;     while (h > l) {       if (str[l++] != str[h--]) {         return -1;       }     }     return 1;   }   int32_t main() {     string s;     cin >> s;     long long n = s.size();     string ans =  YES ;     for (long long i = 0; i < n; i++) {       if (s[i] ==  A  || s[i] ==  H  || s[i] ==  I  || s[i] ==  M  ||           s[i] ==  O  || s[i] ==  T  || s[i] ==  U  || s[i] ==  V  ||           s[i] ==  W  || s[i] ==  X  || s[i] ==  Y ) {       } else {         ans =  NO ;       }     }     if (isPalindrome(s) == 1 && ans ==  YES ) {       cout << ans << endl;       ;     } else {       cout <<  NO  << endl;       ;     }   }