malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int check_year_age(int y1, int y2) {     if (y1 - y2 > 18) return 2;     if (y1 - y2 == 18) return 1;     return 0;   }   bool check_month_day_age(int d1, int d2, int m1, int m2, int y1, int y2) {     if (check_year_age(y1, y2) == 1) {       if (m1 == m2) {         if (d1 >= d2) return 1;         return 0;       }       if (m1 > m2) return 1;       return 0;     }     if (check_year_age(y1, y2) == 2) return 1;     return 0;   }   bool check_day_month_year_valid(int d2, int m2, int y2) {     if (m2 > 12) return 0;     if (y2 % 4 != 0 || m2 != 2) {       if (m2 == 2) {         if (d2 > 28) return 0;       } else {         if (m2 == 1 || m2 == 3 || m2 == 5 || m2 == 7 || m2 == 8 || m2 == 10 ||             m2 == 12) {           if (d2 > 31) return 0;         } else if (d2 > 30)           return 0;       }     } else if (d2 > 29)       return 0;     return 1;   }   int chartoint(char x1, char x2) { return (x1 -  0 ) * 10 + (x2 -  0 ); }   char s[8];   int main() {     int d1, m1, y1, d2, m2, y2;     bool OK = 0;     scanf( %s , s);     d1 = chartoint(s[0], s[1]);     m1 = chartoint(s[3], s[4]);     y1 = chartoint(s[6], s[7]);     scanf( %s , s);     d2 = chartoint(s[0], s[1]);     m2 = chartoint(s[3], s[4]);     y2 = chartoint(s[6], s[7]);     if (check_month_day_age(d1, d2, m1, m2, y1, y2) &&         check_day_month_year_valid(d2, m2, y2)) {       OK = 1;     }     if (check_month_day_age(d1, m2, m1, d2, y1, y2) &&         check_day_month_year_valid(m2, d2, y2)) {       OK = 1;     }     if (check_month_day_age(d1, y2, m1, m2, y1, d2) &&         check_day_month_year_valid(y2, m2, d2)) {       OK = 1;     }     if (check_month_day_age(d1, y2, m1, d2, y1, m2) &&         check_day_month_year_valid(y2, d2, m2)) {       OK = 1;     }     if (check_month_day_age(d1, d2, m1, y2, y1, m2) &&         check_day_month_year_valid(d2, y2, m2)) {       OK = 1;     }     if (check_month_day_age(d1, m2, m1, y2, y1, d2) &&         check_day_month_year_valid(m2, y2, d2)) {       OK = 1;     }     if (OK)       printf( YES n );     else       printf( NO n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     long long a, b;     cin >> t;     while (t--) {       cin >> a >> b;       long long temp = a + b;       if (a - b == 1) {         int flag = 0;         long long i;         int n = sqrt(temp);         if (temp <= 1) {           cout <<  NO  << endl;           continue;         }         if (temp <= 3) {           cout <<  YES  << endl;           continue;         }         if (temp % 2 == 0) {           cout <<  NO  << endl;           continue;         }         for (i = 3; i <= n + 1; i += 2) {           if ((temp % (1ll * i)) == 0) {             flag = 1;             break;           }         }         if (flag)           cout <<  NO  << endl;         else           cout <<  YES  << endl;       } else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);     ;     string a;     int n;     cin >> a >> n;     for (int i = 0; i < a.length() && n; ++i) {       char x = a[i];       int y = i;       for (int j = i + 1; j <= min((int)a.length() - 1, i + n) && n; ++j)         if (x < a[j]) x = a[j], y = j;       if (y != i) {         n -= y - i;         while (i != y) {           swap(a[y - 1], a[y]);           y--;         }       }     }     cout << a << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = (long long)1e9 + 7;   const int inf = (int)1e9 + 7;   const double eps = 1e-7;   const double pi = 3.14159265359;   const int N = (int)1e4;   const int K = 4;   long long n, k;   long long dp[N][K];   signed main() {     scanf( %lld%lld , &n, &k);     if (k == 1) printf( 1 );     if (k == 2) printf( %lld , n * (n - 1) / 2 + 1);     if (k == 3) printf( %lld , n * (n - 1) * (n - 2) / 3 + n * (n - 1) / 2 + 1);     if (k == 4)       printf( %lld , n * (n - 1) * (n - 2) * (n - 3) / 8 * 3 +                          n * (n - 1) * (n - 2) / 3 + n * (n - 1) / 2 + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   bool a[1001][1001];   bool used[1001][1001];   struct T {     int i, j, d;     T(int i, int j, int d) : i(i), j(j), d(d) {}   };   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         char ch;         cin >> ch;         if (ch ==  # ) a[i][j] = true;       }     queue<T> q;     q.push(T(n, 0, 0));     used[n][0] = true;     while (!q.empty()) {       int i = q.front().i, j = q.front().j, d = q.front().d;       q.pop();       if (i == 1) {         cout << d;         return 0;       }       if (i != 0)         for (int k = 1; k <= m; k++)           if (a[i][k] && !used[0][k]) {             q.push(T(0, k, d + 1));             used[0][k] = true;           }       if (j != 0)         for (int k = 1; k <= n; k++)           if (a[k][j] && !used[k][0]) {             q.push(T(k, 0, d + 1));             used[k][0] = true;           }     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int nod(int a, int b) {     while (a && b) {       int c = a % b;       a = b;       b = c;     }     return a | b;   }   int Abs(int a) { return a >= 0 ? a : -a; }   int main() {     int n, m;     cin >> n >> m;     vector<vector<int> > e(n);     for (int i = 0; i < m; ++i) {       int a, b;       scanf( %d%d , &a, &b);       a--;       b--;       e[a].push_back(b);     }     vector<int> d(n, -1);     queue<int> q;     q.push(0);     d[0] = 0;     int r = 0;     while (!q.empty()) {       int i = q.front();       q.pop();       int dd = d[i] + 1;       for (int j = 0; j < (int)e[i].size(); ++j) {         int a = e[i][j];         if (d[a] >= 0)           r = nod(r, Abs(d[a] - dd));         else {           q.push(a);           d[a] = dd;         }       }     }     int c = 0;     for (int i = 0; i < n; ++i)       if (d[i] >= 0 && d[i] % r == 0) c++;     printf( %d n%d n , r, c);     for (int i = 0; i < n; ++i)       if (d[i] >= 0 && d[i] % r == 0) printf( %d  , i + 1);     return 0;   }
#include <bits/stdc++.h>   const int N = 500000;   int n, k;   char s[N + 1], t[N + 1];   int main() {     scanf( %d%d%s%s , &n, &k, s, t);     int r = 0;     long long ans = 0;     for (int i = 0; i < n; ++i) {       if (r < k) {         r *= 2;         r += t[i] - s[i];       }       r = std::min(r, k);       ans += r == k ? r : r + 1;     }     printf( %lld n , ans);     return 0;   }
#include<bits/stdc++.h>   #define inf 2000000000   #define eb emplace_back   #define pb push_back   #define fi first   #define se second   #define fastio ios::sync_with_stdio(false);cin.tie(NULL)   #define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())   using namespace std;   typedef long long ll;   typedef pair<int,int> pii;   typedef vector<int> vi;   typedef vector<pair<int,int>> vii;   typedef set<int> si;   typedef multiset<int> msi;   typedef map<int,int> mii;   int ara[100][100],lcnt[100],wcnt[100];   int main()   {       int t;       int i,j,k;       int n,res;       cin>>t;       while(t--){           cin>>n;           for(i=0;i<n;i++)               for(j=0;j<n;j++)                   ara[i][j]=2;           for(i=0;i<n;i++){               wcnt[i]=(n-1)/2;               lcnt[i]=n-1-(n-1)/2;               ara[i][i]=0;           }              if(n%2==0){               for(i=0;i<n;i++)                   lcnt[i]--;               for(i=0;i<n;i+=2){                   ara[i][i+1]=0;                   ara[i+1][i]=0;                  }              }           //for(i=0;i<n;i++){            //       cout<<wcnt[i]<<   <<lcnt[i]<<endl;                  //}               for(i=0;i<n;i++){                   //cout<<wcnt[i]<<   <<lcnt[i]<<endl;                   for(j=0;j<n;j++){                       if(ara[i][j]==2 && wcnt[i] && lcnt[j]){                           wcnt[i]--;                           lcnt[j]--;                           ara[i][j]=1;                           ara[j][i]=-1;                       }                   }               }               for(i=0;i<n-1;i++){                   for(j=i+1;j<n;j++){                       cout<<ara[i][j]<<   ;                   }               }               cout<<  n ;                }   }
#include <bits/stdc++.h>   using namespace std;   constexpr int inf = 1e9 + 7;   constexpr long long md = 1e6;   void solve(int testi) {     int n;     cin >> n;     if (n == 0) {       cout << 1 <<   n ;       ;       return;     }     vector<int> digits = {6, 8, 4, 2};     cout << digits[n % digits.size()] <<   n ;     ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     long long testn = 1;     for (long long testi = 1; testi <= testn; testi++) {       solve(testi);     }   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   void solve() {     int n, m;     cin >> n >> m;     vector<vector<char> > v(n + 1, vector<char>(m + 1));     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         cin >> v[i][j];       }     }     vector<vector<int> > pf(n + 1, vector<int>(m + 1));     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         pf[i][j] = pf[i - 1][j] + pf[i][j - 1] - pf[i - 1][j - 1];         pf[i][j] += ((v[i][j] ==  X ) ? 1 : 0);       }     }     auto get = [&](int x, int y, int x1, int y1) {       return (pf[x1][y1] - pf[x1][y - 1] - pf[x - 1][y1] + pf[x - 1][y - 1]);     };     auto check = [&](int side) {       vector<vector<int> > add(n + 1, vector<int>(m + 1));       for (int i = 1; i + 2 * side <= n; ++i) {         for (int j = 1; j + 2 * side <= m; ++j) {           long long area = (2 * side + 1) * (2 * side + 1);           if (get(i, j, i + 2 * side, j + 2 * side) == area) {             ++add[i][j];             if (i + 2 * side < n) --add[i + 2 * side + 1][j];             if (j + 2 * side < m) --add[i][j + 2 * side + 1];             if (i + 2 * side < n && j + 2 * side < m)               ++add[i + 2 * side + 1][j + 2 * side + 1];           }         }       }       vector<vector<int> > pf1(n + 1, vector<int>(m + 1));       for (int i = 1; i <= n; ++i) {         for (int j = 1; j <= m; ++j) {           pf1[i][j] =               pf1[i - 1][j] + pf1[i][j - 1] - pf1[i - 1][j - 1] + add[i][j];           int a = !!pf1[i][j], b = ((v[i][j] ==  X ) ? 1 : 0);           if (a ^ b) return 0;         }       }       return 1;     };     int l = 0, r = min(n, m), mid, ans = 1;     while (l <= r) {       mid = l + r >> 1;       if (check(mid))         ans = mid, l = mid + 1;       else         r = mid - 1;     }     cout << ans <<   n ;     int side = ans;     vector<vector<char> > res(n + 1, vector<char>(m + 1,  . ));     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (i + 2 * side <= n && j + 2 * side <= m) {           long long area = (2 * side + 1) * (2 * side + 1);           if (get(i, j, i + 2 * side, j + 2 * side) == area)             res[i + side][j + side] =  X ;         }       }     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) cout << res[i][j];       cout <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int q = 1;     while (q--) solve();   }
#include <bits/stdc++.h>   using namespace std;   inline bool EQ(double num4, double b) { return fabs(num4 - b) < 1e-9; }   const int INF = 1 << 29;   inline int two(int len) { return 1 << len; }   inline int test(int len, int b) { return (len >> b) & 1; }   inline void set_bit(int &len, int b) { len |= two(b); }   inline void unset_bit(int &len, int b) { len &= ~two(b); }   inline int last_bit(int len) { return len & (-len); }   inline int ones(int len) {     int res = 0;     while (len && ++res) len -= len & (-len);     return res;   }   template <class T>   void chmax(T &num4, const T &b) {     num4 = max(num4, b);   }   template <class T>   void chmin(T &num4, const T &b) {     num4 = min(num4, b);   }   inline void add(int &numx, int y) {     numx += y;     if (numx >= 1000000007) numx -= 1000000007;     if (numx < 0) numx += 1000000007;   }   inline int mul(int numx, int y) { return ((long long)numx * y) % 1000000007; }   int gcd(int num4, int b) {     if (b) return gcd(b, num4 % b);     return num4;   }   int power(int num4, int pex) {     int ret = 1;     while (pex) {       if (pex & 1) ret = mul(ret, num4);       num4 = mul(num4, num4);       pex /= 2;     }     return ret;   }   int phi(int len) {     int ret = len;     int idxx = 2;     if (len % idxx == 0) {       ret -= ret / idxx;       while (len % idxx == 0) len /= idxx;     }     for (idxx = 3; idxx * idxx <= len; idxx++)       if (len % idxx == 0) {         ret -= ret / idxx;         while (len % idxx == 0) len /= idxx;       }     if (len > 1) ret -= ret / len;     return ret;   }   using namespace std;   int main() {     bool flags = true;     int num1, num2;     cin >> num1 >> num2;     int vals1 = num1 - 1, v2s = 0, v3s = 0, v4s = num2 - 1, bbs = 0;     for (int i = 0; i < num1; ++i)       for (int j = 0; j < num2; ++j) {         char chh;         cin >> chh;         if (chh ==  B ) {           vals1 = min(vals1, i);           v2s = max(v2s, i);           v4s = min(v4s, j);           v3s = max(v3s, j);           flags = false;           ++bbs;         }       }     if (flags) {       cout << 1;       return 0;     }     int weights = v3s - v4s + 1, h = v2s - vals1 + 1;     if (weights > num1 || h > num2) {       cout << -1;       return 0;     }     int len = max(weights, h);     cout << len * len - bbs << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const long long INF = 1LL << 62;   const long long MINF = -(1LL << 62);   template <typename T>   T getint() {     T val = 0;     char c;     bool neg = false;     while ((c = getchar()) && !(c >=  0  && c <=  9 )) {       neg |= c ==  - ;     }     do {       val = (val * 10) + c -  0 ;     } while ((c = getchar()) && (c >=  0  && c <=  9 ));     return val * (neg ? -1 : 1);   }   const long long mod = 1e9 + 7;   const long long MAXN = 300010;   struct fenwick {     long long arr[MAXN];     fenwick() { memset(arr, 0, sizeof arr); }     void incr(int x, int by) {       for (; x < MAXN; x += (x & (-x))) {         arr[x] = (arr[x] + by) % mod;       }     }     int sum(int x) {       long long sum = 0;       for (; x > 0; x -= (x & (-x))) {         sum = (sum + arr[x]) % mod;       }       return sum;     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     vector<long long> c;     vector<pair<long long, long long>> lst(m);     for (int i = 0; i < m; ++i) cin >> lst[i].first >> lst[i].second;     for (int i = 0; i < m; ++i) {       c.push_back(lst[i].first);       c.push_back(lst[i].second);     }     c.push_back(0);     c.push_back(n);     sort((c).begin(), (c).end());     c.resize(distance(c.begin(), unique((c).begin(), (c).end())));     for (int i = 0; i < m; ++i) {       lst[i].first =           lower_bound((c).begin(), (c).end(), lst[i].first) - c.begin();       lst[i].second =           lower_bound((c).begin(), (c).end(), lst[i].second) - c.begin();     }     int st = 0;     st = lower_bound((c).begin(), (c).end(), st) - c.begin();     n = lower_bound((c).begin(), (c).end(), n) - c.begin();     fenwick f;     sort((lst).begin(), (lst).end(),          [&](pair<long long, long long>& egyik, pair<long long, long long>& masik)              -> bool { return egyik.second < masik.second; });     f.incr(st + 1, 1);     for (auto i : lst) {       long long ways = f.sum(i.second) - f.sum(i.first);       f.incr(i.second + 1, ways);     }     cout << (f.sum(n + 1) - f.sum(n) + mod) % mod <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2002;   int a[N][N], b[N][N], color[N / 2];   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     if (n & 1) {       cout <<  NONE  << endl;       return 0;     }     for (int j = 0; j < n; j++) {       a[0][j] = a[n - 1][n - j - 1] = a[j][0] = a[n - j - 1][n - 1] = j / 2;       b[0][j] = b[n - 1][n - j - 1] = b[j][0] = b[n - j - 1][n - 1] = 1;       if (j == 0 || j == n - 1) continue;       a[1][j] = j & 1 ? (j + 1) / 2 : (j - 1) / 2;       b[1][j] = 0;     }     for (int i = 2; i < n - 1; ++i) {       for (int j = 1; j < n - 1; ++j) {         if (a[i - 2][j] == a[i - 1][j - 1]) {           a[i][j] = a[i - 1][j + 1];         } else {           a[i][j] = a[i - 1][j - 1];         }       }     }     memset(color, -1, sizeof(color));     bool flag = true;     string s;     for (int i = 0; i < n; ++i) {       cin >> s;       for (int j = 0; j < n; ++j) {         int col = (s[j] ==  S );         if (i > 0 && i < n - 1 && j > 0 && j < n - 1) {           if (a[i][j] == a[i - 1][j - 1] && a[i][j] == a[i + 1][j + 1]) {             b[i][j] = 1 ^ b[i - 1][j - 1];           } else {             b[i][j] = 1 ^ b[i - 1][j + 1];           }         }         if (s[j] ==  . ) continue;         if (!b[i][j]) col ^= 1;         int &prv = color[a[i][j]];         if (prv == -1 || prv == col) {           prv = col;         } else {           flag = false;           goto out;         }       }     }   out:     if (flag) {       int c = 0;       for (int i = 0; i < n / 2; ++i) {         c += color[i] != -1;       }       if (c == n / 2) {         cout <<  UNIQUE  << endl;         for (int i = 0; i < n; ++i) {           for (int j = 0; j < n; ++j) {             if (color[a[i][j]] == b[i][j]) {               cout <<  S ;             } else {               cout <<  G ;             }           }           cout << endl;         }       } else {         cout <<  MULTIPLE  << endl;       }     } else {       cout <<  NONE  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cur[100005];   int mark[100005];   int sol[400005];   int csol;   int n, m;   vector<int> E[100005];   inline void dfs(int u, int up) {     mark[u] = 1;     csol++;     sol[csol] = u;     cur[u] ^= 1;     int last = 0;     for (int i = 0; i < E[u].size(); i++)       if (E[u][i] != up && mark[E[u][i]] == 0) {         if (up == 0 && last != 0) {           csol++;           sol[csol] = u;           cur[u] ^= 1;         }         dfs(E[u][i], u);         last = 1;         if (up != 0) {           csol++;           sol[csol] = u;           cur[u] ^= 1;         }       }     if (cur[u])       if (up != 0) {         csol++;         sol[csol] = up;         csol++;         sol[csol] = u;         cur[u] ^= 1;         cur[up] ^= 1;       } else {         csol++;         sol[csol] = u;         cur[u] ^= 1;       }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int p, k;       scanf( %d%d , &p, &k);       E[p].push_back(k);       E[k].push_back(p);     }     for (int i = 1; i <= n; i++) scanf( %d , &cur[i]);     int st = 0;     for (int i = 1; i <= n; i++)       if (cur[i]) st = i;     if (st == 0) {       printf( 0 n );       return 0;     }     dfs(st, 0);     int ok = 1;     for (int i = 1; i <= n; i++)       if (cur[i]) ok = 0;     if (ok) {       printf( %d n , csol);       for (int i = 1; i <= csol; i++) printf( %d  , sol[i]);     } else       printf( -1 n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long a[n], b[n], c[n];     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     map<long long, long long> m;     map<long long, long long>::iterator it;     map<long long, long long>::iterator it1;     for (long long i = 0; i < n; i++) {       cin >> b[i];       m[b[i]]++;     }     for (long long i = 0; i < n; i++) {       it = m.lower_bound(n - a[i]);       it1 = m.lower_bound(0);       if (it != m.end()) {         c[i] = (it->first + a[i]) % n;         m[it->first]--;         if (m[it->first] == 0) m.erase(it);       } else if (it1 != m.end()) {         c[i] = (it1->first + a[i]) % n;         m[it1->first]--;         if (m[it1->first] == 0) m.erase(it1);       }     }     for (long long i = 0; i < n; i++) {       cout << c[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int N = 2e5 + 100;   int t[20 * N], ls[20 * N], rs[20 * N], a[N], root[N];   int cur_size = 1;   void upd(int &v, int u, int l, int r, int pos, int x) {     v = cur_size++;     t[v] = t[u] + x, ls[v] = ls[u], rs[v] = rs[u];     if (l + 1 == r) {       return;     }     int mid = (l + r) / 2;     if (pos < mid)       upd(ls[v], ls[u], l, mid, pos, x);     else       upd(rs[v], rs[u], mid, r, pos, x);     t[v] = t[ls[v]] + t[rs[v]];   }   int get(int v, int l, int r, int ql, int qr) {     if (qr <= l || r <= ql) return 0;     if (ql <= l && r <= qr) return t[v];     int mid = (l + r) / 2;     return get(ls[v], l, mid, ql, qr) + get(rs[v], mid, r, ql, qr);   }   signed main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n, k;     cin >> n >> k;     vector<int> pos[N];     for (int i = 1; i <= n; i++) {       cin >> a[i];       pos[a[i]].push_back(i);     }     for (int i = 1; i <= n; i++) {       int p =           lower_bound(pos[a[i]].begin(), pos[a[i]].end(), i) - pos[a[i]].begin();       upd(root[i], root[i - 1], 1, n + 1, i, 1);       if (p >= k) {         p -= k;         upd(root[i], root[i], 1, n + 1, pos[a[i]][p], -1);       }     }     int q;     cin >> q;     int ans = 0;     while (q--) {       int l, r;       cin >> l >> r;       l = (l + ans) % n + 1;       r = (r + ans) % n + 1;       if (l > r) swap(l, r);       ans = get(root[r], 1, n + 1, l, r + 1);       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       long long int ans;       long long int f = 0;       for (long long int i = 3; i <= 360; i++) {         if ((n * i) % 180 == 0 && (n * i) / 180 <= i - 2) {           f = 1;           ans = i;           break;         }       }       if (f == 1)         cout << ans << endl;       else         cout << -1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 7;   const int inf = 0x3f3f3f;   char s[maxn];   char str[4] =  RGB ;   int main() {     int q;     scanf( %d , &q);     while (q--) {       int n, m;       scanf( %d%d , &n, &m);       scanf( %s , s);       int minn = inf;       n -= m;       for (int i = 0; i <= n; i++) {         for (int j = 0; j < 3; j++) {           int jishu = 0, temp;           temp = (j <= 1 ? j : 2);           for (int k = 0; k < m; k++) {             if (s[i + k] != str[(temp + k) % 3]) {               jishu++;             }           }           minn = min(minn, jishu);         }       }       printf( %d n , minn);     }   }