malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 300000 + 10;   int n, a[MAXN], p[MAXN];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i], p[a[i]] = i;     for (int i = 0; i < n; i++) {       for (int j = min(i + 100, n - 1); j > i; j--) {         int nx = 2 * a[j] - a[i], nxt = 2 * a[i] - a[j];         if (nx > 0 && nx <= n && p[nx] > j) return cout <<  YES  << endl, 0;         if (nxt > 0 && nxt <= n && p[nxt] < i) return cout <<  YES  << endl, 0;       }     }     cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   ostream& operator<<(ostream& os, vector<T> V) {     os <<  [  ;     for (auto v : V) os << v <<    ;     return os <<  ] ;   }   template <class T>   ostream& operator<<(ostream& os, set<T> S) {     os <<  {  ;     for (auto s : S) os << s <<    ;     return os <<  } ;   }   template <class L, class R>   ostream& operator<<(ostream& os, pair<L, R> P) {     return os <<  (  << P.first <<  ,  << P.second <<  ) ;   }   template <class L, class R>   ostream& operator<<(ostream& os, map<L, R> M) {     os <<  {  ;     for (auto m : M) os <<  (  << m.F <<  :  << m.S <<  ) ;     return os <<  } ;   }   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   const int R = 65;   char G[R][R];   int solve() {     int n, m;     cin >> n >> m;     bool all = true, none = true;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         cin >> G[i][j];         if (G[i][j] ==  A )           none = false;         else           all = false;       }     }     if (all) return 0;     if (none) return -1;     bool row = true;     for (int i = 1; i <= m; ++i)       if (G[1][i] ==  P ) row = false;     if (row) return 1;     row = true;     for (int i = 1; i <= m; ++i)       if (G[n][i] ==  P ) row = false;     if (row) return 1;     row = true;     for (int i = 1; i <= n; ++i)       if (G[i][1] ==  P ) row = false;     if (row) return 1;     row = true;     for (int i = 1; i <= n; ++i)       if (G[i][m] ==  P ) row = false;     if (row) return 1;     if (G[1][1] ==  A ) return 2;     if (G[1][m] ==  A ) return 2;     if (G[n][1] ==  A ) return 2;     if (G[n][m] ==  A ) return 2;     for (int i = 2; i <= n - 1; ++i) {       bool eq = true;       for (int j = 1; j <= m; ++j) {         if (G[i][j] ==  P ) eq = false;       }       if (eq) return 2;     }     for (int i = 2; i <= m - 1; ++i) {       bool eq = true;       for (int j = 1; j <= n; ++j) {         if (G[j][i] ==  P ) eq = false;       }       if (eq) return 2;     }     bool any = false;     for (int i = 2; i <= n - 1; ++i) {       if (G[i][1] ==  A  || G[i][m] ==  A ) any = true;     }     for (int i = 2; i <= m - 1; ++i) {       if (G[1][i] ==  A  || G[n][i] ==  A ) any = true;     }     if (any) return 3;     return 4;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cout << fixed << setprecision(25);     int t;     cin >> t;     while (t--) {       int ans = solve();       if (ans != -1)         cout << ans <<   n ;       else         cout <<  MORTAL               <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define     mod     1000000007   #define     int      long long    #define     pb      push_back   #define     endl      n    #define     ff      first   #define     ss      second   #define     FIO     ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);   #define     all(x)  (x).begin(),(x).end()   int32_t main()   {         FIO         int t; cin >> t;         while(t--)         {               int n, x, t; cin >> n >> x >> t;               if(x > t) cout << 0 << endl;               else                {                     int a = t/x;                     int ans=0;                     if(a>n)                           ans+= (n*(n-1))/2;                     else                     {                           ans+= (n-a) * a;                           ans+= (a*(a-1))/2;                     }                     cout << ans << endl;               }         }   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 2e5 + 7;   long long parent[MAXN], rank1[MAXN];   vector<pair<long long, pair<long long, long long>>> edges;   void makest(long long v) {     parent[v] = v;     rank1[v] = 0;   }   long long find(long long v) {     if (v == parent[v]) return v;     return parent[v] = find(parent[v]);   }   void merge(long long a, long long b) {     a = find(a);     b = find(b);     if (a != b) {       if (rank1[a] < rank1[b]) swap(a, b);       parent[b] = a;       if (rank1[a] == rank1[b]) rank1[a]++;     }   }   signed main() {     long long n, m, mini = 1e14, node, ans = 0;     cin >> n >> m;     long long a[n + 1];     for (long long i = 1; i <= n; ++i) {       cin >> a[i];       if (mini > a[i]) {         mini = a[i];         node = i;       }     }     for (long long i = 1; i <= n; ++i) {       makest(i);     }     long long x, y, z;     for (long long i = 1; i <= m; ++i) {       cin >> x >> y >> z;       edges.push_back({z, {x, y}});     }     for (long long i = 1; i <= n; ++i) {       if (i != node) {         edges.push_back({mini + a[i], {i, node}});       }     }     sort(edges.begin(), edges.end());     for (auto t : edges) {       x = t.second.first;       y = t.second.second;       z = t.first;       if (find(x) != find(y)) {         ans += z;         merge(x, y);       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, n, k, h;   int main() {     int arr[3];     cin >> arr[0] >> arr[1] >> arr[2];     int y = 1, b = 2, r = 3;     while (y < arr[0] && b < arr[1] && r < arr[2]) {       y++;       r++;       b++;     }     cout << y + b + r;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10, SQ = 780;   const long long inf = 1e18;   long long dp[2][SQ];   vector<int> v[maxn];   int n, m;   long long ans;   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       int a, b;       scanf( %d%d , &a, &b);       if ((a = n + 1 - a) >= (SQ - 1))         ans += 3;       else         v[b].push_back(a);     }     for (int i = 1; i < SQ; i++) dp[0][i] = inf;     dp[0][0] = 0;     for (int i = 1; i <= n; i++) {       dp[i & 1][SQ - 1] = inf;       sort(v[i].begin(), v[i].end());       int num = 0;       for (int j = SQ - 2; j >= 0; j--) {         dp[i & 1][j] = min(dp[i & 1][j + 1],                            num + min(dp[(i + 1) & 1][0] + (j == 0 ? 0 : 2) +                                          1ll * ((j * (j + 1)) / 2),                                      dp[(i + 1) & 1][j + 1]));         if (!v[i].empty() && v[i].back() == j) num += 3, v[i].pop_back();       }     }     ans += dp[n & 1][0];     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long modex(long long a, long long b) {     long long ans = 1LL;     while (b) {       if (b % 2) {         ans *= a;         ans %= 1000000009;       }       a *= a;       a %= 1000000009;       b /= 2LL;     }     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m, x, y;     cin >> n >> m;     if (m <= 20) {       x = 1LL << m;       if (x <= n) {         cout << 0 <<   n ;         return 0;       }     }     x = modex(2LL, m);     y = 1LL;     for (int i = 1; i <= n; i++) {       if (i >= x)         y *= (x - i + 1000000009);       else         y *= (x - i);       y %= 1000000009;     }     cout << y <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int a, b;       cin >> a >> b;       if ((abs(a - b)) % 2) {         cout << -1 << endl;         continue;       }       if (a == b && b == 0) {         cout << 0 << endl;         continue;       }       if (a == b)         cout << 1 << endl;       else         cout << 2 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int ckmax(int &a, int b) { return a < b ? a = b, 1 : 0; }   inline int ckmin(int &a, int b) { return a > b ? a = b, 1 : 0; }   int n, r, x[1010];   double y[1010];   int main() {     scanf( %d%d , &n, &r);     for (int i = 1; i <= n; ++i) {       scanf( %d , x + i);       y[i] = r;       for (int j = 1; j < i; ++j) {         if (abs(x[i] - x[j]) <= 2 * r) {           int d = abs(x[i] - x[j]);           double l = sqrt(4 * r * r - d * d);           y[i] = max(y[i], y[j] + l);         }       }       printf( %.10f  , y[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename A, typename B>   ostream& operator<<(ostream& o, pair<A, B> a) {     return o << a.first <<     << a.second;   }   template <typename A, typename B>   istream& operator>>(istream& o, pair<A, B>& a) {     return o >> a.first >> a.second;   }   const int mod = 1e9 + 7, abc = 864197532, N = 300087, K = 111;   long long int modpow(long long int a, int b) {     long long int ans = 1;     for (; b; b >>= 1, a = a * a % mod) {       if (b & 1) ans = ans * a % mod;     }     return ans;   }   int inter(vector<int> l, vector<int> r) {     int ll = *max_element(l.begin(), l.end()),         rr = *min_element(r.begin(), r.end());     if (ll <= rr) return rr - ll + 1;     return 0;   }   void add(long long int& a, long long int b) {     a += b;     if (a >= mod) a -= mod;   }   void del(long long int& a, long long int b) {     a -= b;     if (a < 0) a += mod;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> l(n), r(n), sz(n), inv(n);     for (int i = 0; i < n; ++i) cin >> l[i];     long long int al = 1;     for (int i = 0; i < n; ++i) {       cin >> r[i];       sz[i] = r[i] - l[i] + 1;       al = al * sz[i] % mod;       inv[i] = modpow(sz[i], mod - 2);     }     long long int square = 0, sum = 0;     for (int i = 0; i + 1 < n; ++i) {       add(sum, inter({l[i], l[i + 1]}, {r[i], r[i + 1]}) * al % mod * inv[i] %                    mod * inv[i + 1] % mod);     }     square = sum;     for (int i = 0; i + 2 < n; ++i) {       add(square, inter({l[i], l[i + 1], l[i + 2]}, {r[i], r[i + 1], r[i + 2]}) *                       al % mod * inv[i] % mod * inv[i + 1] % mod * inv[i + 2] %                       mod * 2 % mod);     }     long long int now = 0;     for (int i = 0; i + 1 < n; ++i)       add(now, 1ll * inter({l[i], l[i + 1]}, {r[i], r[i + 1]}) * inv[i] % mod *                    inv[i + 1] % mod);     for (int i = 0; i + 1 < n; ++i) {       if (i - 1 >= 0)         del(now, 1ll * inter({l[i - 1], l[i]}, {r[i - 1], r[i]}) * inv[i - 1] %                      mod * inv[i] % mod);       del(now, 1ll * inter({l[i], l[i + 1]}, {r[i], r[i + 1]}) * inv[i] % mod *                    inv[i + 1] % mod);       if (i + 2 < n)         del(now, 1ll * inter({l[i + 1], l[i + 2]}, {r[i + 1], r[i + 2]}) *                      inv[i + 1] % mod * inv[i + 2] % mod);       add(square, now * inter({l[i], l[i + 1]}, {r[i], r[i + 1]}) % mod * inv[i] %                       mod * inv[i + 1] % mod * al % mod);       if (i - 1 >= 0)         add(now, 1ll * inter({l[i - 1], l[i]}, {r[i - 1], r[i]}) * inv[i - 1] %                      mod * inv[i] % mod);       add(now, 1ll * inter({l[i], l[i + 1]}, {r[i], r[i + 1]}) * inv[i] % mod *                    inv[i + 1] % mod);       if (i + 2 < n)         add(now, 1ll * inter({l[i + 1], l[i + 2]}, {r[i + 1], r[i + 2]}) *                      inv[i + 1] % mod * inv[i + 2] % mod);     }     cout << ((square + mod - sum * n * 2 % mod) * modpow(al, mod - 2) +              1ll * n * n) %                 mod;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[1005];   long long dp[1005];   long long dpsum[1005];   bool b[1005];   long long ch[1005][1005];   long long gc(int c, int x) {     if (x == 0 || c == x) return 1;     if (!ch[c][x]) {       ch[c][x] = (gc(c - 1, x - 1) + gc(c - 1, x)) % 998244353;     }     return ch[c][x];   }   int getdp(int x) {     if (!b[x]) {       b[x] = 1;       if (a[x] > 0) {         for (int i = x + a[x] + 1; i <= n + 1; ++i) {           dp[x] =               (dp[x] + gc(i - x - 2, a[x] - 1) * (1LL + dpsum[i])) % 998244353;         }       }     }     return dp[x];   }   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];     }     long long ans = 0;     for (int i = n; i >= 1; --i) {       dpsum[i] = dpsum[i + 1] + getdp(i);       dpsum[i] %= 998244353;     }     for (int i = 1; i <= n; ++i) {       ans = ans + getdp(i);       ans %= 998244353;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     short n, pos, l, r;     cin >> n >> pos >> l >> r;     if (1 == l && n == r) {       cout <<  0 ;       return 0;     }     if (1 == l) {       cout << abs(r - pos) + 1;       return 0;     }     if (n == r) {       cout << abs(pos - l) + 1;       return 0;     }     short time = 0;     if (abs(r - pos) <= abs(pos - l)) {       time += abs(r - pos) + 1;       pos = r;       time += abs(pos - l) + 1;     } else {       time += abs(pos - l) + 1;       pos = l;       time += abs(r - pos) + 1;     }     cout << time;     return 0;   }
#include<bits/stdc++.h>   using namespace std;      int main()   {       ios_base::sync_with_stdio(false);       cin.tie(NULL);              int t,n;       cin>>t;       while(t--)       {           cin>>n;           string str;           cin>>str;                      int cnt_t=0,cnt_m=0;                      for(int i=0;i<n;i++)           {               if(str[i]== T )               {                   cnt_t++;               }               else               {                   cnt_m++;               }           }                      if(cnt_t!=2*cnt_m)           {               cout<< NO <<endl;           }                      else           {               int x=0,y=0;                              int flag=0;                              // forward check                              for(int i=0;i<n;i++)               {                   if(str[i]== T )                   {                       x++;                   }                   if(str[i]== M )                   {                       y++;                   }                   if(y>x)                   {                       cout<< NO <<endl;                       flag=1;                       break;                   }               }                              if(flag==0)               {                   x=0;                   y=0;                                                         // backward check                   for(int i=n-1;i>=0;i--)                   {                       if(str[i]== T )                       {                           x++;                       }                       if(str[i]== M )                       {                           y++;                       }                       if(y>x)                       {                           cout<< NO <<endl;                           flag=1;                           break;                       }                   }               }                              if(flag==0)               {                   cout<< YES <<endl;               }           }                  }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   char getc() {     char c = getchar();     while ((c <  A  || c >  Z ) && (c <  a  || c >  z ) && (c <  0  || c >  9 ))       c = getchar();     return c;   }   int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); }   int read() {     int x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 )       x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();     return x * f;   }   int n, a[200010], pre[200010][32], suf[200010][32], PRE[200010], SUF[200010];   long long ans;   signed main() {     n = read();     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 32; j++) pre[i][j] = pre[i - 1][j];       for (int j = 0; j < 32; j++)         if (a[i - 1] & (1 << j)) pre[i][j] = i - 1;     }     for (int j = 0; j < 32; j++) suf[n + 1][j] = n + 1;     for (int i = n; i >= 1; i--) {       for (int j = 0; j < 32; j++) suf[i][j] = suf[i + 1][j];       for (int j = 0; j < 32; j++)         if (a[i + 1] & (1 << j)) suf[i][j] = i + 1;     }     a[0] = a[n + 1] = 1000000010;     for (int i = 1; i <= n; i++) {       int j = i - 1;       while (a[j] < a[i]) j = PRE[j];       PRE[i] = j;     }     SUF[n + 1] = n + 1;     for (int i = n; i >= 1; i--) {       int j = i + 1;       while (a[j] <= a[i]) j = SUF[j];       SUF[i] = j;     }     for (int i = 1; i <= n; i++) {       int x = PRE[i], y = SUF[i];       int u = PRE[i], v = SUF[i];       for (int j = 0; j < 32; j++)         if (!(a[i] & (1 << j))) u = max(u, pre[i][j]), v = min(v, suf[i][j]);       ans += 1ll * (SUF[i] - i) * (u - PRE[i]) + 1ll * (i - u) * (SUF[i] - v);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool pal(string s) {     long long n = s.size();     for (long long i = 0; i < n / 2; i++)       if (s[i] != s[n - i - 1]) return false;     return true;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long test = 1;     while (test--) {       long long n, k, x, ab = 1e10, p, c = 0, f;       cin >> n >> k >> x;       vector<long long> v(n);       for (long long i = 0; i < n; i++) {         cin >> v[i];         if (abs(v[i]) < abs(ab)) {           ab = abs(v[i]);           p = i;         }         if (v[i] < 0) c++;       }       if (c % 2 == 0) {         f = abs(ab) / x + 1;         f = min(f, k);         k -= f;         if (v[p] < 0)           v[p] += f * x;         else           v[p] -= f * x;       }       set<pair<long long, long long> > s;       for (long long i = 0; i < n; i++) s.insert({abs(v[i]), i});       while (k > 0) {         k--;         p = s.begin()->second;         if (v[p] < 0) {           v[p] -= x;           s.erase(s.begin());           s.insert({abs(v[p]), p});         } else {           v[p] += x;           s.erase(s.begin());           s.insert({v[p], p});         }       }       for (long long i = 0; i < n; i++) cout << v[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 550;   char grid[maxn][maxn];   int rdp[maxn][maxn], cdp[maxn][maxn], dp[maxn][maxn];   int val[maxn][maxn];   int main() {     int n, m, q, c1, c2, r1, r2;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) scanf( %s , grid[i]);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (!i)           rdp[i][j] = 0;         else {           rdp[i][j] = rdp[i - 1][j];           if (grid[i][j] ==  .  && grid[i - 1][j] ==  . ) rdp[i][j]++;         }         if (!j)           cdp[i][j] = 0;         else {           cdp[i][j] = cdp[i][j - 1];           if (grid[i][j] ==  .  && grid[i][j - 1] ==  . ) cdp[i][j]++;         }       }     }     scanf( %d , &q);     while (q--) {       scanf( %d%d%d%d , &r1, &c1, &r2, &c2);       r1--, c1--, r2--, c2--;       int ans = 0;       for (int i = r1; i <= r2; i++) ans += cdp[i][c2] - cdp[i][c1];       for (int j = c1; j <= c2; j++) ans += rdp[r2][j] - rdp[r1][j];       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 100, maxp = 20;   int n, a[maxp][maxp], ma[(1 << maxp)], cur[1 << maxp], dp[1 << maxp], cnt[maxn],       f[maxp][maxn];   int ans, mp, p;   char s[maxn];   vector<int> pos[20];   void solve() {     dp[mp] = 1;     for (int i = mp; i >= 0; i--) {       if (!dp[i]) continue;       for (int j = 0; j < p; j++)         if ((i >> j) & 1) dp[(i ^ (1 << j))] = ma[(i ^ (1 << j))];     }     return;   }   void init() {     for (int i = 1; i <= n; i++) {       cnt[s[i] -  a ]++;       pos[s[i] -  a ].push_back(i);       for (int c = 0; c < p; c++) f[c][i + 1] = f[c][i] + (s[i] == ( a  + c));     }     for (int i = 0; i <= mp; i++) ma[i] = 1;     for (int i = 0; i < p; i++) {       for (int j = 0; j <= i; j++) {         memset(cur, 0, sizeof(cur));         if (a[i][j]) continue;         int pos1 = 0, pos2 = 0;         while (pos1 < pos[i].size() && pos2 < pos[j].size()) {           if (i == j && pos[i][pos1] == pos[j][pos2]) {             pos2++;             continue;           }           int m = 0;           if (pos[i][pos1] < pos[j][pos2]) {             for (int c = 0; c < p; c++) {               if (f[c][pos[j][pos2]] - f[c][pos[i][pos1] + 1] != 0) {                 m |= (1 << c);               }             }             pos1++;           } else {             for (int c = 0; c < p; c++) {               int pp1 = f[c][pos[j][pos2] + 1];               int pp2 = f[c][pos[i][pos1]];               if (f[c][pos[i][pos1]] - f[c][pos[j][pos2] + 1] != 0) {                 m = m ^ (1 << c);               }             }             pos2++;           }           if ((m >> i) & 1) continue;           if ((m >> j) & 1) continue;           m = m ^ (mp);           cur[m] = 1;         }         for (int i = 0; i <= mp; i++) cur[i] = !cur[i];         for (int ii = mp; ii > 0; ii--) {           if (cur[ii]) continue;           for (int jj = 0; jj < p; jj++) {             if (jj != i && jj != j && (ii >> jj) & 1) {               cur[(ii ^ (1 << jj))] = 0;             }           }           ma[ii] &= cur[ii];         }       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> p;     ans = n;     mp = (1 << p) - 1;     for (int i = 1; i <= n; i++) cin >> s[i];     for (int i = 0; i < p; i++)       for (int j = 0; j < p; j++) cin >> a[i][j];     init();     solve();     for (int i = 0; i <= mp; i++) {       int res = 0;       if (!dp[i]) continue;       for (int j = 0; j < p; j++)         if ((i >> j) & 1) {           res += cnt[j];         }       ans = min(ans, res);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long n, l, r, ans = 0;   bool kk(long long x, long long i) {     if (x == 1) {       if (i == 1)         return 1;       else         return 0;     } else {       long long t = 1, g;       while (t <= x) t *= 2;       t--;       g = t / 2;       if (g + 1 == i) {         if (x % 2)           return 1;         else           return 0;       } else {         if (i <= g)           return kk(x / 2, i);         else {           return kk(x / 2, i - g - 1);         }       }     }   }   int main() {     long long i, j;     cin >> n >> l >> r;     if (n == 0) {       cout << 0;       return 0;     }     for (i = l; i <= r; i++) {       if (kk(n, i) == 1) ans++;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const int INF = 1061109567;   const long long LINF = 4557430888798830399ll;   void TestCase() {     long long d;     scanf( %lld , &d);     d %= 360;     if (d < 0) d += 360;     int ans = INF, cnt = 0;     for (int i = 0; i < 4; ++i) {       int nd = abs(d - 90 * i);       if (min(nd, 360 - nd) < ans) {         ans = min(nd, 360 - nd);         cnt = i;       }     }     printf( %d n , cnt);   }   int main() {     int t = 1;     for (int i = 1; i <= t; ++i) {       TestCase();     }     return 0;   }