malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long int mod = 998244353;   long double eps = 1e-12;   long long int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};   long long int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};   long long int n, res = 0, k = 0, h, ans = 0, m;   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long int lcm(long long int x, long long int y) {     return (x * y) / gcd(x, y);   }   long long int pot(long long int a, long long int b) {     long long int r = 1;     while (b) {       if (b % 2) r = (r * a) % mod;       a = (a * a) % mod;       b /= 2;     }     return r % mod;   }   void pr(long long int a[], long long int n) {     for (long long int i = 1; i <= n; i++) cout << a[i] <<   n ;     cout <<   n ;   }   void read(long long int a[], long long int n) {     for (long long int i = 1; i <= n; i++) cin >> a[i];   }   void yes() { cout <<  Yes n ; }   void no() { cout <<  No n ; }   vector<long long int> v[300015];   void add_edge(long long int x, long long int y) {     v[x].push_back(y);     v[y].push_back(x);   }   string s2, ch =   , s, s1 =   , t;   vector<pair<string, long long int> > vs;   vector<pair<pair<long long int, long long int>, long long int> > vvv, vvv2;   vector<pair<long long int, long long int> > vv, vv2;   long long int a[300015], b[300015] = {0};   long long int bit[300015];   void update(long long int x, long long int val) {     for (; x <= n; x += x & -x) bit[x] += val;   }   long long int query(long long int x) {     long long int sum = 0;     for (; x > 0; x -= x & -x) {       sum += bit[x];     }     return sum;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long int i = 0, x = 0, z = 0, y = 0, j = 0, q, mx = 0, mm, idx = 0,                   ok = 0, l = 0, r, negatif = 0, positif = 0;     set<pair<long long int, long long int> >::iterator itw, ith;     multiset<long long int>::iterator it;     multiset<long long int> mst, mst2;     cin >> n;     read(a, n);     for (i = 1; i <= (long long int)(n); i++) {       vv.push_back({a[i], -i});     }     sort(vv.rbegin(), vv.rend());     for (i = 0; i < vv.size(); i++) vv[i].second = abs(vv[i].second);     cin >> q;     for (i = 1; i <= (long long int)(q); i++) {       long long int k, pos;       cin >> k >> pos;       vvv.push_back({{k, pos}, i});     }     sort(vvv.begin(), vvv.end());     j = 0;     for (i = 0; i < vvv.size(); i++) {       long long int k = vvv[i].first.first;       long long int pos = vvv[i].first.second;       long long int qidx = vvv[i].second;       while (j < k) {         long long int val = vv[j].first;         long long int idx = vv[j].second;         update(idx, 1);         j++;       }       l = 1;       r = n;       res = 0;       while (l <= r) {         long long int mid = (l + r) / 2;         long long int sum = query(mid);         if (sum < pos) {           res = mid;           l = mid + 1;         } else {           r = mid - 1;         }       }       res++;       b[qidx] = a[res];     }     pr(b, q);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int nmax = 1e5 + 42, mod = 1e9 + 7;   int n, inp[nmax];   vector<int> seen[nmax], dvd[nmax];   int phi[nmax];   int cnt[nmax];   long long sum_gcd(vector<int> cur) {     long long alone = 0;     for (auto w : cur) alone = (alone + w) % mod;     long long together = 0;     for (auto p : cur) {       for (auto q : dvd[p]) {         together = (together + 1LL * phi[q] * cnt[q]) % mod;         cnt[q]++;       }     }     for (auto p : cur) {       for (auto q : dvd[p]) cnt[q] = 0;     }     long long ret = (alone + together * 2) % mod;     return ret;   }   int main() {     scanf( %i , &n);     for (int i = 1; i <= n; i++) scanf( %i , &inp[i]);     for (int i = 1; i < nmax; i++) phi[i] = i;     for (int i = 2; i < nmax; i++)       if (phi[i] == i) {         for (int j = i; j < nmax; j = j + i) phi[j] = phi[j] / i * (i - 1);       }     for (int i = 1; i <= n; i++) {       for (int j = i; j <= n; j = j + i) seen[i].push_back(inp[j]);     }     for (int i = 1; i < nmax; i++) {       for (int j = i; j < nmax; j = j + i) dvd[j].push_back(i);     }     long long outp = 0;     for (int i = 1; i <= n; i++)       outp = (outp + 1LL * phi[i] * sum_gcd(seen[i])) % mod;     printf( %lld n , outp);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void cal(long long number, long long x, long long s) {     long long d = number ^ x;     long long temp = 2 * number - (s + d);     if (temp % 2 == 0) {       cout << 3 << endl;       cout << d <<     << temp / 2 <<     << temp / 2 << endl;     }     if (temp % 2 == 1) {       number -= 1;       d = number ^ x;       temp = 2 * number - (s + d);       cout << 3 << endl;       cout << d <<     << temp / 2 <<     << temp / 2 << endl;     }   }   void solve() {     long long n;     cin >> n;     vector<long long> a(n);     long long s = 0, x = 0, number = 0;     for (long long i = 0; i < 57; i++) {       number = number | 1LL << i;     }     for (long long i = 0; i < n; i++) {       cin >> a[i];       s = s + a[i];       x = x ^ a[i];     }     cal(number, x, s);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int kor = 1e7;   int main() {     long long n, rad, v;     cin >> n >> rad >> v;     for (int i = 0; i < n; i++) {       int l, r;       cin >> l >> r;       long long d = r - l;       int ma = 0;       while (d < kor) {         d *= 10;         rad *= 10;         ma++;       }       long long mnv = 0;       long long mxv = d;       while (mnv != mxv) {         long long cv = (mnv + mxv) / 2;         double cd = cv + rad * sin((double)cv / rad);         if (cd < (d / 2)) {           mnv = cv + 1;           continue;         }         mxv = cv;       }       long long ev = mnv;       mnv = 0;       mxv = d;       while (mnv != mxv) {         long long cv = (mnv + mxv) / 2;         double cd = cv - rad * sin((double)cv / rad);         if (cd < (d / 2)) {           mnv = cv + 1;           continue;         }         mxv = cv;       }       long long bv = min(ev, mnv);       bv *= 2;       double t = (double)bv / v;       while (ma > 0) {         t /= 10;         rad /= 10;         ma--;       }       cout << setprecision(20) << t << endl;     }     cin >> n;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, v[5005];   int ans(int st, int dr, int lvl) {     if (st > dr) return 0;     int mini = 1000000001;     int minipoz;     for (int i = st; i <= dr; i++) {       if (v[i] <= lvl) {         return ans(st, i - 1, lvl) + ans(i + 1, dr, lvl);       }       if (v[i] < mini) {         mini = v[i];         minipoz = i;       }     }     return min(dr - st + 1, mini - lvl + ans(st, minipoz - 1, mini) +                                 ans(minipoz + 1, dr, mini));   }   int main() {     cin >> n;     for (i = 1; i <= n; i++) cin >> v[i];     cout << ans(1, n, 0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n;     int m;     scanf( %I64d %d , &n, &m);     std::vector<long long int> v(n, 0);     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d%d , &x, &y);       v[x - 1]++;       v[y - 1]++;     }     long long int res = 0;     for (int i = 0; i < n; i++) {       res -= v[i] * (n - 1 - v[i]);     }     res /= 2;     res += (n * (n - 1) * (n - 2)) / 6;     printf( %I64d , res);   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> z, q;   long long w, p = 10, l = 60;   long long mul(long long x, long long y) {     long long z = 0;     for (; y; y >>= 1, x = x * 2 % p)       if (y & 1) z = (z + x) % p;     return z;   }   pair<long long, long long> F(long long x) {     if (x == 0) return pair<long long, long long>(0, 1);     if (x & 1) {       pair<long long, long long> u = F(x - 1);       return pair<long long, long long>(u.second, (u.first + u.second) % p);     } else {       pair<long long, long long> u = F(x / 2);       return pair<long long, long long>(           mul(u.first, 2 * u.second + p - u.first),           (mul(u.first, u.first) + mul(u.second, u.second)) % p);     }   }   int main() {     cin >> w;     for (int i = 0; i < l; i++)       if (F(i).first == w % p) z.push_back(i);     for (int i = 0; i < 12; i++) {       p *= 10;       q.clear();       for (long long j : z)         for (int k = 0; k < 10; k++)           if (F(j + k * l).first == w % p) q.push_back(j + k * l);       z.swap(q);       l *= 10;     }     if (!z.size())       puts( -1 );     else       cout << *min_element(z.begin(), z.end());   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   string to_string(string s) { return     + s +    ; }   string to_string(char s) { return string(1, s); }   string to_string(const char *s) { return to_string((string)s); }   string to_string(bool b) { return (b ?  true  :  false ); }   template <typename A>   string to_string(A);   template <typename A, typename B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   template <typename A>   string to_string(A v) {     bool f = 1;     string r =  { ;     for (const auto &x : v) {       if (!f) r +=  ,  ;       f = 0;       r += to_string(x);     }     return r +  } ;   }   void debug_out() { cout << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cout <<     << to_string(H);     debug_out(T...);   }   const int N = 1e5 + 10;   int n, k;   vector<pair<int, int>> g[N];   vector<pair<long long, long long>> A1[N];   pair<long long, long long> f(int u, int p) {     auto &a1 = A1[u];     for (auto it : g[u])       if (it.first != p) {         int v = it.first, c = it.second;         auto now = f(v, u);         a1.emplace_back(now.first + c, max(now.first, now.second) + c);       }     sort((a1).begin(), (a1).end());     reverse((a1).begin(), (a1).end());     pair<long long, long long> ans(0, 0);     for (auto i = (0); i <= (min(int(a1.size()), k - 1) - 1); ++i) {       ans.first += a1[i].first;       ans.second += a1[i].first;     }     long long cur = ans.second;     for (auto i = (0); i <= (int(a1.size()) - 1); ++i) {       if (i <= k - 2) {         ans.second =             max(ans.second, cur - a1[i].first + a1[i].second +                                 (k - 1 < int(a1.size()) ? a1[k - 1].first : 0));       } else {         ans.second = max(ans.second, cur + a1[i].second);       }     }     return ans;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> k;     for (auto i = (1); i <= (n - 1); ++i) {       int x, y, c;       cin >> x >> y >> c;       g[x].emplace_back(y, c);       g[y].emplace_back(x, c);     }     pair<int, int> ans = f(0, -1);     cout << max(ans.first, ans.second) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n % 2 != 0)       cout <<  -1  << endl;     else {       for (int i = 1; i <= n; i++) {         if (i % 2 == 0)           cout << i - 1 <<    ;         else           cout << i + 1 <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N;   int arr[51][51];   bool checkSum(int num, int row, int col) {     for (int i = 0; i < N; i++) {       for (int j = 0; j < N; j++) {         if (arr[row][i] + (long long int)arr[j][col] == num) {           return true;         }       }     }     return false;   }   int main() {     scanf( %d , &N);     for (int i = 0; i < N; i++) {       for (int j = 0; j < N; j++) {         scanf( %d , &arr[i][j]);       }     }     bool flag = true;     for (int i = 0; i < N && flag; i++) {       for (int j = 0; j < N && flag; j++) {         if (arr[i][j] != 1) {           flag = checkSum(arr[i][j], i, j);         }       }     }     if (flag) {       printf( Yes n );     } else {       printf( No n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   double e[100010], r[100010], p[100010];   int main() {     int n;     {       scanf( %d , &n);       for (int i = 0; i < n; i++) {         scanf( %lf , &p[i]);       }       e[0] = p[0];       r[0] = p[0];       for (int i = 1; i < n; i++) {         e[i] = e[i - 1] + p[i] + 2.0 * p[i] * r[i - 1];         r[i] = (r[i - 1] + 1.0) * p[i];       }       printf( %.8lf n , e[n - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool cmp(pair<char, int> &a, pair<char, int> &b) { return a.second < b.second; }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     string s[3];     int i;     bool imp = false;     unordered_map<char, int> m;     vector<pair<char, int>> v;     for (i = 0; i < 3; i++) {       cin >> s[i];     }     for (i = 0; i < 3; i++) {       if (s[i][1] ==  > ) {         m[s[i][0]]++;         m[s[i][2]]--;       } else {         m[s[i][0]]--;         m[s[i][2]]++;       }     }     for (auto it = m.begin(); it != m.end(); it++) {       v.push_back(make_pair(it->first, it->second));     }     if (v[0].second == v[1].second || v[1].second == v[2].second ||         v[0].second == v[2].second) {       imp = true;     }     if (imp) {       cout <<  Impossible n ;     } else {       sort(v.begin(), v.end(), cmp);       for (i = 0; i < v.size(); i++) {         cout << v[i].first;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void _dbg(string) { cout << endl; }   template <class H, class... T>   void _dbg(string s, H h, T... t) {     int l = s.find( , );     cout << s.substr(0, l) <<   =   << h <<  ,  ;     _dbg(s.substr(l + 1), t...);   }   template <class T, class U>   ostream &operator<<(ostream &o, const pair<T, U> &p) {     o <<  (  << p.first <<  ,  << p.second <<  ) ;     return o;   }   template <class T>   ostream &operator<<(ostream &o, const vector<T> &v) {     o <<  [ ;     for (T t : v) {       o << t <<  , ;     }     o <<  ] ;     return o;   }   class UnionFind {    public:     vector<int> par, rank;     UnionFind(int sz) : par(sz, -1), rank(sz, 0) {}     int find(int x) {       if (par[x] < 0)         return x;       else         return par[x] = find(par[x]);     }     void unite(int x, int y) {       x = find(x);       y = find(y);       if (x == y) return;       if (rank[x] < rank[y]) {         par[y] += par[x];         par[x] = y;       } else {         par[x] += par[y];         par[y] = x;         if (rank[x] == rank[y]) rank[x]++;       }     }     inline bool same(int x, int y) { return find(x) == find(y); }     inline int size(int x) { return -par[find(x)]; }   };   int main() {     int n;     cin >> n;     vector<int> v(n);     for (int i = (int)(0); i < (int)(n); i++) scanf( %d , &v[i]);     for (int i = (int)(0); i < (int)(n); i++) v[i]--;     UnionFind uf(n + 1);     vector<bool> appeared(n + 1, false);     appeared[n] = true;     cout <<  1  ;     for (int i = (int)(0); i < (int)(n); i++) {       if (v[i] > 0 && appeared[v[i] - 1]) uf.unite(v[i] - 1, v[i]);       if (appeared[v[i] + 1]) uf.unite(v[i], v[i] + 1);       appeared[v[i]] = true;       int sz = uf.size(n) - 1;       printf( %d%c , (i + 2) - sz,    n [i == n - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   int main() {     double s, f, r, v;     int n;     scanf( %d%lf%lf , &n, &r, &v);     while (n--) {       scanf( %lf%lf , &s, &f);       double ans = 0, d = f - s;       int cnt = (int)floor(d / (2 * pi * r));       ans += cnt * 2 * pi * r / v;       d -= cnt * (2 * pi * r);       d /= 2;       double L = 0, R = d;       for (int _i = 0; _i < 60; _i++) {         double mid = (L + R) / 2;         if (mid + sin(mid / r) * r > d)           R = mid;         else           L = mid;       }       ans += 2 * L / v;       printf( %f n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long d1[] = {0, 2, 3, 1};   long long fn1(long long start, long long pos, long long len) {     long long zzz = len / 4;     if (len == 1) return start;     for (long long i = 0; i < 4; i++) {       long long l = i * zzz;       long long r = l + (zzz - 1);       if (l <= pos && pos <= r) return fn1(start + d1[i] * zzz, pos - l, zzz);     }     return -1;   }   long long d2[] = {0, 3, 1, 2};   long long fn2(long long start, long long pos, long long len) {     long long zzz = len / 4;     if (len == 1) return start;     for (long long i = 0; i < 4; i++) {       long long l = i * zzz;       long long r = l + (zzz - 1);       if (l <= pos && pos <= r) return fn2(start + d2[i] * zzz, pos - l, zzz);     }     return -1;   }   long long solve() {     long long n;     cin >> n;     n--;     long long row = n / 3;     long long col = n % 3;     if (col == 0) {       long long pos = row;       long long temp = 1;       long long start = 1;       while (true) {         if (pos - temp >= 0) {           pos -= temp;           temp *= 4;           start *= 4;           continue;         }         break;       }       cout << start + pos <<   n ;     }     if (col == 1) {       long long pos = row;       long long temp = 1;       long long start = 2;       while (true) {         if (pos - temp >= 0) {           pos -= temp;           temp *= 4;           start *= 4;           continue;         }         break;       }       cout << fn1(start, pos, temp) <<   n ;     }     if (col == 2) {       long long pos = row;       long long temp = 1;       long long start = 3;       while (true) {         if (pos - temp >= 0) {           pos -= temp;           temp *= 4;           start *= 4;           continue;         }         break;       }       cout << fn2(start, pos, temp) <<   n ;     }     return 0;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     ;     long long t = 1;     cin >> t;     while (t-- != 0) {       long long stat = solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> g[100009], df;   long long n, v[100009];   long long used[100009], x, sum, plu[100009], minu[100009], br;   void dfs(int node) {     used[node] = 1;     long long mxpl = 0, mxmi = 0;     for (int i = 0; i < g[node].size(); i++) {       if (used[g[node][i]] == 0) {         dfs(g[node][i]);         mxpl = max(mxpl, plu[g[node][i]]);         mxmi = max(mxmi, minu[g[node][i]]);       }     }     if (v[node] + mxpl > mxmi) {       plu[node] = mxpl;       minu[node] = mxpl + v[node];     } else {       minu[node] = mxmi;       plu[node] = minu[node] - v[node];     }   }   int main() {     cin >> n;     for (int i = 1; i < n; i++) {       int a, b;       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     for (int i = 1; i <= n; i++) {       cin >> v[i];     }     dfs(1);     for (int i = 1; i <= n; i++) {     }     sum = minu[1] + plu[1];     cout << sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long num[100500];   long long d1[15], d2[15];   int main() {     long long n;     long long ans = 0;     scanf( %lld , &n);     for (int i = 1; i <= n; i++) {       scanf( %lld , &num[i]);     }     for (int i = 1; i <= n; i++) {       long long digit = 0;       long long a = num[i];       long long di = 1;       while (a) {         d1[++digit] = a % 10;         a /= 10;       }       for (int k = 1; k <= digit; k++) {         ans += d1[k] * di + d1[k] * di * 10;         di *= 100;         di = di % 998244353;         ans = ans % 998244353;       }     }     ans *= n;     ans = ans % 998244353;     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T sqr(T x) {     return x * x;   }   template <typename T>   T abs(T x) {     return x > 0 ? x : -x;   }   int cur = 0;   string get_next() {     string ans =   ;     if (cur >= 26) {       ans =  B ;     } else {       ans =  A ;     }     ans += (char)( a  + cur % 26);     cur++;     return ans;   }   int main() {     int n, k;     cin >> n >> k;     vector<bool> used(n - k + 1);     for (int i = 0; i < n - k + 1; i++) {       string s;       cin >> s;       if (s ==  NO ) {         used[i] = true;       }     }     vector<string> ans(n);     for (int i = 0; i < n; i++) {       if (i >= k - 1 && used[i - k + 1]) {         ans[i] = ans[i - k + 1];       } else {         ans[i] = get_next();       }     }     for (int i = 0; i < n; i++) {       cout << ans[i] <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M;   long long ans, add[400009], sum[400009];   set<pair<int, pair<int, int> > > segm;   int mod(int x) {     if (x < 0) return -x;     return x;   }   void split(int nod, int l1, int l2) {     if (add[nod] == 0) return;     int f1 = nod << 1, f2 = (nod << 1) + 1;     sum[f1] += 1LL * add[nod] * l1, sum[f2] += 1LL * add[nod] * l2;     add[f1] += add[nod], add[f2] += add[nod];     add[nod] = 0;   }   void U(int nod, int st, int dr, int x, int y, int val) {     if (x <= st && dr <= y) {       add[nod] += val;       sum[nod] += 1LL * val * (dr - st + 1);       return;     }     int mij = (st + dr) >> 1;     split(nod, mij - st + 1, dr - mij);     if (x <= mij) U(nod << 1, st, mij, x, y, val);     if (y > mij) U((nod << 1) + 1, mij + 1, dr, x, y, val);     sum[nod] = sum[nod << 1] + sum[(nod << 1) + 1];   }   void Q(int nod, int st, int dr, int x, int y) {     if (x <= st && dr <= y) {       ans += sum[nod];       return;     }     int mij = (st + dr) >> 1;     split(nod, mij - st + 1, dr - mij);     if (x <= mij) Q(nod << 1, st, mij, x, y);     if (y > mij) Q((nod << 1) + 1, mij + 1, dr, x, y);   }   void Update(int L, int R, int val) {     set<pair<int, pair<int, int> > >::iterator it = segm.lower_bound(                                                    make_pair(L, make_pair(0, 0))),                                                it2;     if (it->second.first < L) {       int A = it->second.first, B = it->first, C = it->second.second;       if (B > R) {         U(1, 1, N, L, R, mod(val - C));         segm.erase(it);         segm.insert(make_pair(L - 1, make_pair(A, C)));         segm.insert(make_pair(B, make_pair(R + 1, C)));         segm.insert(make_pair(R, make_pair(L, val)));         return;       }       U(1, 1, N, L, B, mod(val - C));       segm.erase(it);       segm.insert(make_pair(L - 1, make_pair(A, C)));       it = segm.lower_bound(make_pair(L, make_pair(0, 0)));     }     while (1) {       if (it == segm.end()) break;       if (it->second.first > R) break;       if (it->first > R) {         int A = it->second.first, B = it->first, C = it->second.second;         U(1, 1, N, A, R, mod(val - C));         segm.erase(it);         segm.insert(make_pair(B, make_pair(R + 1, C)));         break;       }       it2 = it, it2++;       U(1, 1, N, it->second.first, it->first, mod(val - it->second.second));       segm.erase(it);       it = it2;     }     segm.insert(make_pair(R, make_pair(L, val)));   }   int main() {     scanf( %d %d , &N, &M);     for (int i = 1; i <= N; i++) segm.insert(make_pair(i, make_pair(i, i)));     while (M--) {       int tip, a, b, c;       scanf( %d , &tip);       if (tip == 1) {         scanf( %d %d %d , &a, &b, &c);         Update(a, b, c);       } else {         scanf( %d %d , &a, &b), ans = 0LL;         Q(1, 1, N, a, b);         printf( %I64d n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<int> q;   const int maxn = 360;   int main() {     int t, n;     scanf( %d , &t);     while (t--) {       scanf( %d , &n);       int num = 360 / (180 - n);       int ans = 0;       if (num * (180 - n) != 360) num++;       for (int i = num; i <= 360; i++) {         if ((n * i) % 180 != 0) continue;         ans = i;         if (ans != 0) break;       }       if (ans == 0)         printf( -1 n );       else         printf( %d n , ans);     }     return 0;   }