malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 5e4 + 10, max_node = N * 200;   int n, m, q, C, c[N], a[N], size[N], heavy[N], dfn[N], dfn_t, top[N], father[N],       tt, lo[max_node], ro[max_node], addv[max_node];   long long sum[max_node], sum2[max_node];   vector<int> graph[N], nodes[N];   void dfs1(int u) {     size[u] = 1;     for (auto v : graph[u]) {       dfs1(v);       size[u] += size[v];       if (size[v] > size[heavy[u]]) {         heavy[u] = v;       }     }   }   void dfs2(int u, int t) {     top[u] = t;     dfn[u] = ++dfn_t;     if (heavy[u]) {       dfs2(heavy[u], t);       for (auto v : graph[u]) {         if (v != heavy[u]) {           dfs2(v, v);         }       }     }   }   void add(int l, int r, int o, int v) {     addv[o] += v;     sum2[o] += ((sum[o] << 1) + (r - l + 1) * v) * v;     sum[o] += (r - l + 1) * v;   }   void push_down(int l, int r, int o) {     if (addv[o]) {       int mid = l + r >> 1;       if (!lo[o]) {         lo[o] = ++tt;       }       if (!ro[o]) {         ro[o] = ++tt;       }       add(l, mid, lo[o], addv[o]);       add(mid + 1, r, ro[o], addv[o]);       addv[o] = 0;     }   }   void push_up(int o) {     sum[o] = sum[lo[o]] + sum[ro[o]];     sum2[o] = sum2[lo[o]] + sum2[ro[o]];   }   void modify(int l, int r, int& o, int ql, int qr, int v) {     if (!o) {       o = ++tt;     }     if (ql <= l && r <= qr) {       return add(l, r, o, v);     } else {       int mid = l + r >> 1;       push_down(l, r, o);       if (ql <= mid) {         modify(l, mid, lo[o], ql, qr, v);       }       if (qr > mid) {         modify(mid + 1, r, ro[o], ql, qr, v);       }       push_up(o);     }   }   struct info_t {     int root;     void init(vector<int>& nodes) {       for (auto v : nodes) {         for (int x = v; x; x = father[top[x]]) {           modify(1, n, root, dfn[top[x]], dfn[x], 1);         }       }     }     void update(int u, int type) {       for (int x = u; x; x = father[top[x]]) {         modify(1, n, root, dfn[top[x]], dfn[x], type);       }     }     double get_answer(int c) {       double result = (double)C * C;       result -= 2.0 * C * c * sum[root] / n;       result += 1.0 * c * c * sum2[root] / n;       return result;     }   } info[N];   int main() {     scanf( %d%d%d%d , &n, &m, &q, &C);     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       nodes[a[i]].push_back(i);     }     for (int i = 2; i <= n; ++i) {       scanf( %d , &father[i]);       graph[father[i]].push_back(i);     }     for (int i = 1; i <= m; ++i) {       scanf( %d , &c[i]);     }     dfs1(1);     dfs2(1, 1);     for (int i = 1; i <= m; ++i) {       info[i].init(nodes[i]);     }     while (q--) {       int type, x, w;       scanf( %d , &type);       if (type == 1) {         scanf( %d%d , &x, &w);         info[a[x]].update(x, -1);         a[x] = w;         info[a[x]].update(x, 1);       } else {         scanf( %d , &x);         printf( %.12lf n , info[x].get_answer(c[x]));       }     }     return 0;   }
#include <bits/stdc++.h>   const long long int mod = 1000000007;   const long long int AM = 2e6 + 5;   using namespace std;   long long int powm(long long int a, long long int b, long long int n) {     long long int x = 1, y = a;     while (b > 0) {       if (b % 2 == 1) {         x = (x * y) % n;       }       y = (y * y) % n;       b /= 2;     }     return x % n;   }   long long int pow(long long int x, long long int y) {     long long int res = 1;     while (y > 0) {       if (y & 1) res = ((res) * (x));       y = y >> 1;       x = ((x) * (x));     }     return res;   }   long long int fact(long long int n) {     long long int ans = 1;     for (long long int i = 1; i <= n; i++) ans *= i;     return ans;   }   long long int nCr(long long int n, long long int r) {     if (r > n - r) r = n - r;     long long int ans = 1, i;     for (i = 1; i <= r; i++) {       ans *= n - r + i;       ans /= i;     }     return ans;   }   bool isPrime(long long int n) {     if (n <= 1) return false;     for (long long int i = 2; i < n; i++)       if (n % i == 0) return false;     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long int n;     cin >> n;     long long int s = sqrt(n), f1, f2;     if (s * s >= n) {       f1 = s;       f2 = s;     } else if (s * (s + 1) >= n) {       f1 = s;       f2 = s + 1;     } else {       f1 = s + 1;       f2 = s + 1;     }     cout << f1 + f2;   }
#include <bits/stdc++.h>   using namespace std;   int f[305][305], rf[305][305], g[305][305], rg[305][305];   int a[305][305];   int n, m, s, t1, t2, t3;   int ans1, ans2, ans3, ans4, Min = 1999999999;   set<pair<int, int> > S;   int C(int first, int second) {     if (first < second) return t2;     if (first == second) return t1;     return t3;   }   int G(int i, int j, int k, int l) {     int ans = (f[i][l] - f[i][k]) + (rf[j][l] - rf[j][k]);     ans += (g[l][j] - g[l][i]);     return ans;   }   int main() {     scanf( %d %d %d , &n, &m, &s);     scanf( %d %d %d , &t1, &t2, &t3);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %d , &a[i][j]);     for (int i = 1; i <= n; i++) {       f[i][1] = 0;       for (int j = 2; j <= m; j++)         f[i][j] = f[i][j - 1] + C(a[i][j - 1], a[i][j]);       rf[i][1] = 0;       for (int j = 2; j <= m; j++)         rf[i][j] = rf[i][j - 1] + C(a[i][j], a[i][j - 1]);     }     for (int i = 1; i <= m; i++) {       g[i][1] = 0;       for (int j = 2; j <= n; j++)         g[i][j] = g[i][j - 1] + C(a[j - 1][i], a[j][i]);       rg[i][1] = 0;       for (int j = 2; j <= n; j++)         rg[i][j] = rg[i][j - 1] + C(a[j][i], a[j - 1][i]);     }     for (int i = 1; i <= n; i++)       for (int j = i + 2; j <= n; j++) {         S.clear();         for (int k = m; k >= 1; k--) {           if (k <= m - 2) S.insert(make_pair(G(i, j, 1, k + 2), k + 2));           if (S.empty()) continue;           int tmp = s + f[i][k] + rf[j][k] - rg[k][j] + rg[k][i];           set<pair<int, int> >::iterator it = S.upper_bound(make_pair(tmp, 0));           if (it != S.end()) {             pair<int, int> tmpg = *it;             if (abs(tmpg.first - tmp) < Min) {               Min = abs(tmpg.first - tmp);               ans1 = i, ans2 = j, ans3 = k, ans4 = tmpg.second;             }           }           if (it == S.begin()) continue;           it--;           pair<int, int> tmpg = *it;           if (abs(tmpg.first - tmp) < Min) {             Min = abs(tmpg.first - tmp);             ans1 = i, ans2 = j, ans3 = k, ans4 = tmpg.second;           }         }       }     printf( %d %d %d %d n , ans1, ans3, ans2, ans4);     return 0;   }
#include <bits/stdc++.h>   template <class T>   T abs(T x) {     return x > 0 ? x : -x;   }   const int MAXINT = 1111 * 1111 * 1111;   const long long MAXLINT = MAXINT * 1ll * MAXINT;   const long double EPS = 1e-10;   using namespace std;   int n, m, x, y, z, p;   int a, b;   void reverse_left() {     int aa = a, bb = b;     a = m - b + 1;     b = aa;     swap(n, m);   }   void reverse_middle() { b = m - b + 1; }   void reverse_right() {     int aa = a, bb = b;     b = n - a + 1;     a = bb;     swap(n, m);   }   void solve() {     cin >> n >> m >> x >> y >> z >> p;     int N = n, M = m;     x %= 4;     z %= 4;     y %= 2;     while (p--) {       n = N;       m = M;       cin >> a >> b;       for (int i = 0; i < x; i++) reverse_right();       for (int i = 0; i < y; i++) reverse_middle();       for (int i = 0; i < z; i++) reverse_left();       cout << a <<     << b << endl;     }   }   int main() { solve(); }
#include <bits/stdc++.h>   using namespace std;   set<long long> s;   map<long long, long long> m;   vector<long long> v;   long long n, a[100010], b[100010], dp[100010], mx = 0;   bool mark[100010];   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> a[i];       if (i == 1)         dp[i] = a[i];       else         dp[i] = dp[i - 1] + a[i];     }     for (long long i = 1; i <= n; i++) cin >> b[i];     for (long long i = n; i > 0; i--) {       v.push_back(mx);       long long r, l;       mark[b[i]] = 1;       if (b[i] < n) {         if (mark[b[i] + 1] == 1) {           set<long long>::iterator it = s.lower_bound(b[i]);           r = *it;         } else           r = b[i];       } else         r = b[i];       s.insert(r);       if (b[i] > 1) {         if (mark[b[i] - 1] == 1) {           s.erase(b[i] - 1);         }       }       m[r] = m[b[i] - 1] + dp[r] - dp[b[i] - 1];       if (m[r] > mx) mx = m[r];     }     for (long long i = v.size() - 1; i >= 0; i--) cout << v[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void _print(long long t) { cerr << t; }   void _print(int t) { cerr << t; }   void _print(string t) { cerr << t; }   void _print(char t) { cerr << t; }   void _print(long double t) { cerr << t; }   void _print(double t) { cerr << t; }   void _print(unsigned long long t) { cerr << t; }   template <class T, class V>   void _print(pair<T, V> p);   template <class T>   void _print(vector<T> v);   template <class T>   void _print(vector<vector<T>> v);   template <class T>   void _print(set<T> v);   template <class T, class V>   void _print(map<T, V> v);   template <class T>   void _print(multiset<T> v);   template <class T, class V>   void _print(pair<T, V> p) {     cerr <<  { ;     _print(p.first);     cerr <<  , ;     _print(p.second);     cerr <<  } ;   }   template <class T>   void _print(vector<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(vector<vector<T>> v) {     cerr <<  ==>  << endl;     for (vector<T> vec : v) {       for (T i : vec) {         _print(i);         cerr <<    ;       }       cerr << endl;     }   }   template <class T>   void _print(set<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(multiset<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T, class V>   void _print(map<T, V> v) {     cerr <<  [  ;     for (auto i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   mt19937_64 rang(       chrono::high_resolution_clock::now().time_since_epoch().count());   int rng(int lim) {     uniform_int_distribution<int> uid(0, lim - 1);     return uid(rang);   }   const int INF = 0x3f3f3f3f;   const int mod = 1e9 + 7;   long long mod_exp(long long a, long long b) {     a %= mod;     if (a == 0) return 0LL;     long long res = 1LL;     while (b > 0) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return res;   }   long long mod_inv(long long a) { return mod_exp(a, mod - 2); }   long long GCD(long long a, long long b) { return (b == 0) ? a : GCD(b, a % b); }   void solve() {     long long a1, a2, a3, a4, a5, a6;     cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6;     cout << ((a1 + a2 + a3) * (a1 + a2 + a3)) - (a1 * a1) - (a3 * a3) - (a5 * a5);   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);     srand(chrono::high_resolution_clock::now().time_since_epoch().count());     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[1005];   char t[1000005];   int main() {     scanf( %s , s);     scanf( %s , t);     int len1 = strlen(s);     int len2 = strlen(t);     int le = 0x3f3f3f3f;     int ri = 0x3f3f3f3f;     for (int i = 0, j = 0; j < len2; j++) {       if (s[i] == t[j]) i++;       if (i == len1) {         le = j;         break;       }     }     for (int i = len1 - 1, j = len2 - 1; j >= 0; j--) {       if (s[i] == t[j]) i--;       if (i == -1) {         ri = j;         break;       }     }     if ((le - ri) == (len1 - 1))       cout <<  0  << endl;     else {       int ans = ri - le;       cout << ans << endl;     }   }
#include <bits/stdc++.h>   int N, K;   std::string S;   int main() {     std::cin >> N >> K;     std::cin >> S;     std::string t = S;     std::string s =   ;     for (int l = 1; l < N; ++l) {       if (S.substr(0, l) == S.substr(N - l, l)) {         t = S.substr(0, N - l);         s = S.substr(N - l, l);       }     }     while (K--) std::cout << t;     std::cout << s <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     vector<int> candies(n);     for (int i = 0; i < n; i++) cin >> candies[i];     int i = 0, j = n - 1;     int store_a = 0, store_b = 0;     int turn = 0, sum_a = 0, sum_b = 0;     while (i <= j) {       if (turn % 2 == 0) {         int str_temp = 0;         while ((str_temp <= store_b) && (i <= j)) {           str_temp += candies[i];           i++;         }         store_a = str_temp;         sum_a += store_a;       } else {         int str_tem = 0;         while ((str_tem <= store_a) && (i <= j)) {           str_tem += candies[j];           j--;         }         store_b = str_tem;         sum_b += store_b;       }       turn++;     }     cout << turn <<     << sum_a <<     << sum_b <<   n ;   }   int main() {     int t;     cin >> t;     while (t) {       solve();       t--;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast ,  unroll-loops ,  no-stack-protector )   using namespace std;   using ll = long long;   using ld = double;   using pii = pair<int, int>;   using uint = unsigned int;   using ull = unsigned long long;   mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());   default_random_engine generator;   void solve();   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout << setprecision(16) << fixed;     cerr << setprecision(16) << fixed;     int tests = 1;     for (int test = 1; test <= tests; ++test) {       solve();     }   }   const int INF = 1e9;   struct Point {     int x, y;   };   void solve() {     int n;     cin >> n;     vector<Point> p(n);     for (int i = 0; i < n; ++i) {       string s;       cin >> s;       int a = 0, b = 0;       for (char c : s) {         a += c ==  B ;         b += c ==  N ;       }       p[i] = {a, b};     }     int minx = INF, maxx = -INF;     int miny = INF, maxy = -INF;     int l = INF, r = -INF;     for (auto [x, y] : p) {       minx = min(minx, x);       maxx = max(maxx, x);       miny = min(miny, y);       maxy = max(maxy, y);       l = min(l, x - y);       r = max(r, x - y);     }     int res = 0;     res = max(res, (maxx - minx + 1) / 2);     res = max(res, (maxy - miny + 1) / 2);     res = max(res, (minx - miny) - l);     res = max(res, r - (minx - miny));     Point best = {minx + res, miny + res};     for (int op = 0; op < 2; ++op) {       int xx = miny + l;       int yy = miny;       int cur = 0;       cur = max(cur, (maxx - xx + 2) / 3);       cur = max(cur, (maxy - yy + 1) / 2);       cur = max(cur, (r - l + 1) / 2);       if (cur < res && cur <= minx - xx) {         res = cur;         best = {xx + 2 * res, yy + res};         if (op) {           swap(best.x, best.y);         }       }       for (int i = 0; i < n; ++i) {         swap(p[i].x, p[i].y);       }       swap(minx, miny);       swap(maxx, maxy);       r *= -1;       l *= -1;       swap(l, r);     }     cout << res << endl;     string ans;     for (int i = 0; i < best.x; ++i) {       ans +=  B ;     }     for (int i = 0; i < best.y; ++i) {       ans +=  N ;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     string s;     cin >> s;     long long w = 0, o = 0;     for (long long i = 0; i < s.length() - 1; i++) {       if (s[i] ==  v  && s[i + 1] ==  v )         w++;       else {         if (s[i] ==  o ) o++;       }     }     if (s[s.length() - 1] ==  o ) o++;     long long x = 0, ans = 0;     for (long long i = 0; i < s.length() - 1; i++) {       if (s[i] ==  v  && s[i + 1] ==  v )         x++;       else {         if (s[i] ==  o ) {           ans += x * (w - x);         }       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int lins, cols;     cin >> lins >> cols;     for (int i(0); i < lins; i++) {       if (i % 2 == 0) {         for (int j(0); j < cols; j++) {           cout <<  # ;         }         cout << endl;       } else if ((i + 1) % 4 == 0) {         cout <<  # ;         for (int j(0); j < cols - 1; j++) {           cout <<  . ;         }         cout << endl;       } else {         for (int j(0); j < cols - 1; j++) {           cout <<  . ;         }         cout <<  # ;         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     int ans = 0;     while (1) {       int maxi = 0;       for (int i = 0; i < n; i++) {         if (arr[i] >= arr[maxi]) maxi = i;       }       if (maxi == 0) break;       ans++;       arr[0]++;       arr[maxi]--;     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t;     t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m, l = 0, p = 0, i, flag = 0, k, j, r = 0, q = 0, t, curr = 0, d,                     x;     cin >> n >> x >> k;     long long a[n];     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     for (long long i = 0; i < n; i++) {       long long r1 = a[i] + (x * k);       if (a[i] % x == 0) {         r1--;       }       r1 -= r1 % x;       long long r2 = r1 + x - 1;       r1 = max(a[i], r1);       auto it = upper_bound(a, a + n, r2);       auto it1 = lower_bound(a, a + n, r1);       p += it - it1;     }     cout << p;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename T1>   T amax(T &a, T1 b) {     if (b > a) a = b;     return a;   }   template <typename T, typename T1>   T amin(T &a, T1 b) {     if (b < a) a = b;     return a;   }   bool isPrime(long long x) {     if (x == 1) return false;     for (long long i = 2; i * i <= x; i++) {       if (x % i == 0) {         return false;       }     }     return true;   }   bool isPowerOfTwo(long long n) {     if (n == 0) return false;     return (ceil(log2(n)) == floor(log2(n)));   }   long long gcdByBit(long long a, long long b) {     if (!a || !b) return a | b;     unsigned shift = __builtin_ctz(a | b);     a >>= __builtin_ctzl(a);     do {       b >>= __builtin_ctzl(b);       if (a > b) {         swap(a, b);       }       b -= a;     } while (b);     return a << shift;   }   long long powerMod(long long n, long long p) {     long long res = 1;     while (p) {       if (p % 2 == 0) {         n = n * 1ll * n % 1000000007;         p /= 2;       } else {         res = res * 1ll * n % 1000000007;         p--;       }     }     return res;   }   long long powerMod2(long long b, long long p, long long m) {     if (p == 0) return 1;     return (b * powerMod2(b, p - 1, m) % m) % m;   }   long long fact(long long n) {     long long res = 1;     for (long long i = 1; i <= n; i++) {       res = res * 1ll * i % 1000000007;     }     return res;   }   long long nCr(long long n, long long r) {     return fact(n) * 1ll * powerMod(fact(r), 1000000007 - 2) % 1000000007 * 1ll *            powerMod(fact(n - r), 1000000007 - 2) % 1000000007;   }   long long arr[300005];   long long ans[300005];   long long parent(long long x) {     if (arr[x] != x) arr[x] = parent(arr[x]);     return arr[x];   }   void Chaliye_Shuru_Karte_Hai() {     for (long long i = 0; i < 300005; i++) arr[i] = i;     long long n, m;     cin >> n >> m;     for (long long i = 0; i < m; i++) {       long long a, b, c;       cin >> a >> b >> c;       for (long long j = parent(a); j <= b; j = parent(j + 1)) {         if (j != c) ans[j] = c, arr[j] = j + 1;       }     }     for (long long i = 1; i < n + 1; i++) cout << ans[i] <<    ;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long tc = 1;     while (tc--) {       Chaliye_Shuru_Karte_Hai();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005;   const int M = 101;   const double EPS = 1e-9;   const int INF = 1e9;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return a * b / gcd(a, b); }   double getDist(complex<double> a, complex<double> b) {     return sqrt((a.real() - b.real()) * (a.real() - b.real()) +                 (a.imag() - b.imag()) * (a.imag() - b.imag()));   }   int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }   long long mod = 1000000007, fib[N], dp[N][N];   long long power(long long base, int p) {     if (!p) return 1;     long long ret = power(base, p / 2);     ret *= ret;     ret %= mod;     if (p & 1) ret *= base, ret %= mod;     return ret;   }   long long modInverse(int a) { return power(a, mod - 2); }   long long ncr(int n, int r) {     return (((fib[n] * modInverse(fib[r])) % mod) * modInverse(fib[n - r])) % mod;   }   bool emty[N], taken[N];   long long solve(int n, int k) {     if (k == 0) return fib[n];     if (k == 1) return (fib[n] * n) % mod;     if (dp[n][k] != -1) return dp[n][k];     long long ret =         (solve(n, k - 1) * n) % mod + (solve(n + 1, k - 2) * (k - 1)) % mod;     return dp[n][k] = ret % mod;   }   int main() {     fib[0] = fib[1] = 1;     for (int i = 2; i < N; i++) fib[i] = (fib[i - 1] * i) % mod;     int n, free = 0, k = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       int a;       scanf( %d , &a);       if (a == -1)         emty[i] = 1;       else         taken[a] = 1;     }     for (int i = 1; i <= n; i++) {       if (emty[i] == 1) {         if (taken[i] == 1)           free++;         else           k++;       }     }     memset(dp, -1, sizeof(dp));     cout << solve(free, k);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, tmp, sum = 1;     int map[200000] = {0};     cin >> n;     for (int i = 0; i < n; i++) {       cin >> tmp;       if (map[tmp] == 0) {         map[tmp]++;       } else         sum++;     }     cout << sum;   }
#include <bits/stdc++.h>   using namespace std;   long long N;   long long i, j;   vector<long long> v;   map<long long, long long> mp;   long long arr[200];   int main() {     scanf( %lld , &N);     for (i = 0; i < N; i++) scanf( %lld , &arr[i]);     sort(arr, arr + N);     long long ans = 0;     for (i = 0; i < N; i++) {       long long get = arr[i];       if (mp[arr[i]] == 1) {         continue;       } else {         ans++;         for (j = 1; j < 200; j++) {           mp[get * j] = 1;         }       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxd = 1e6 + 10;   int a[maxd];   long long sum, ans = 1e18;   vector<long long> b;   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++) sum += a[i];     if (sum == 1) {       printf( -1 n );       return 0;     }     for (long long i = 2; i * i <= sum; i++) {       if (sum % i == 0) {         b.push_back(i);         sum /= i;         i--;       }     }     b.push_back(sum);     for (auto x : b) {       long long res = 0;       sum = 0;       for (int i = 1; i <= n; i++) {         sum += a[i];         sum %= x;         res += min(sum, x - sum);       }       ans = min(res, ans);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a;   vector<int> q;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       bool w = true;       for (int j = 0; j < n; j++) {         scanf( %d , &a);         if (a == 1 || a == 3) w = false;       }       if (w) q.push_back(i + 1);     }     printf( %d n , q.size());     for (int i = 0; i < q.size(); i++) printf( %d  , q[i]);     return 0;   }