malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<long long int> vec;   bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {     return (a.second < b.second);   }   long long int mark[123];   int main() {     std::ios::sync_with_stdio(false);     string str;     cin >> str;     long long int n;     cin >> n;     if (str.size() < n) {       cout <<  impossible ;       return 0;     }     for (long long int i = 0; i < str.size(); i++) {       mark[str[i]]++;     }     long long int ans = 0;     for (long long int i = 0; i < 123; i++) {       if (mark[i] > 0) ans++;     }     if (ans >= n)       cout <<  0 ;     else       cout << n - ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long m, n, i, t, j;     cin >> t;     while (t--) {       long long one = 0, zro = 0, cnt = 0, ans = 0;       cin >> n;       vector<long long> v;       for (long long j = 0; j < n; j++) {         string s;         cin >> s;         for (long long i = 0; i < s.size(); i++) {           if (s[i] ==  1 )             one++;           else             zro++;         }         v.push_back(s.size());       }       sort(v.begin(), v.end());       long long pr = one / 2 + zro / 2;       for (long long i = 0; i < v.size(); i++) {         long long need = v[i] / 2;         if (need <= pr) pr -= need, ans++;       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int x;     int y;     node(int a, int b) {       x = a;       y = b;     }   };   int n, m, k, flag;   vector<node> v;   int vis[10005], dis[10005];   const int inf = 0x3f3f3f3f;   int spfa() {     memset(dis, inf, sizeof(dis));     queue<int> q;     q.push(0);     dis[0] = 0;     while (!q.empty()) {       int Now = q.front();       q.pop();       vis[Now] = 0;       for (int i = 0; i < k; i++) {         if (i == Now) continue;         node to = v[i];         node now = v[Now];         int cost = inf;         if (abs(now.x - to.x) + abs(now.y - to.y) == 1)           cost = 0;         else if (abs(now.x - to.x) <= 2 || abs(now.y - to.y) <= 2)           cost = 1;         if (dis[i] > dis[Now] + cost) {           dis[i] = dis[Now] + cost;           if (!vis[i]) {             q.push(i);           }         }       }     }     if (dis[k - 1] < inf) return dis[k - 1];     return -1;   }   int main() {     ios::sync_with_stdio(false);     ;     while (cin >> n >> m >> k) {       flag = 0;       v.clear();       for (int i = 0; i < k; i++) {         int x, y;         cin >> x >> y;         v.push_back(node(x, y));         if (x == n && y == m) flag = 1;       }       if (!flag) {         k++;         v.push_back(node(n + 1, m + 1));       }       cout << spfa() << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const double pi = acos(-1);   int main() {     ios_base::sync_with_stdio(false);     double w, h, a;     cin >> w >> h >> a;     if (a > 90.0) a = 180.0 - a;     cout.setf(ios::fixed);     cout.precision(10);     if (a < eps) {       cout << w * h;       return 0;     }     a /= 180.0;     a *= pi;     double f = (1 + cos(a)) / sin(a);     double x = (h * f - w) / (f * f - 1);     double y = h - x * f;     if (x >= 0 && y >= 0 && y <= h + eps && x <= w + eps) {       double ans = w * h;       ans -= x * x / tan(a);       ans -= y * y / tan(a);       cout << ans;     } else {       if (w < h) swap(w, h);       cout << h * h / sin(a);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5000 + 10;   char s[N], t[N];   int n, m, dp[N][N];   int main() {     scanf( %d%d%s%s , &n, &m, s + 1, t + 1);     int ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         dp[i][j] = 0;         if (i >= 1) dp[i][j] = max(dp[i][j], dp[i - 1][j] - 1);         if (j >= 1) dp[i][j] = max(dp[i][j], dp[i][j - 1] - 1);         if (i >= 1 && j >= 1 && s[i] == t[j])           dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 2);         ans = max(ans, dp[i][j]);       }     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int in() {     int x;     scanf( %d , &x);     return x;   }   long long lin() {     long long x;     scanf( %lld , &x);     return x;   }   int x[200010];   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) a[i] = in();     int s = 0;     for (int i = 0; i < n; ++i) {       if (s <= 1) {         x[s++] = a[i];       } else if (x[s - 2] == x[s - 1] && x[s - 1] <= a[i]) {         s -= 2;         x[s++] = a[i];       } else if (x[s - 1] == a[i] && a[i] <= x[s - 2]) {         s -= 1;       } else {         x[s++] = a[i];       }     }     if (s <= 1 || (s == 2 && x[0] == x[1])) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double max(double a, double b) {     if (a >= b)       return a;     else       return b;   }   int main() {     double m[5], s, u;     for (int i = 0; i < 5; i++) cin >> m[i];     double sum = 0, sum1;     for (int i = 0; i < 5; i++) {       sum1 = 0;       double x;       cin >> x;       sum1 += ((250 - m[i]) / 250.0) * (500) * float(i + 1);       sum1 -= 50 * x;       sum += max(sum1, double(0.3 * double(i + 1) * 500.0));     }     cin >> s >> u;     cout << sum + 100 * s - 50 * u;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxlongint = 2147483647;   const int P1 = 19260817, P2 = 1000000007, N = 100011, M = 1000011;   long long mi1[M], mi2[M], ni1[M], ni2[M], s1[M], s2[M];   char st[M], Ans[M];   long long powder(int x, int a, const int& P) {     if (!a) return 1;     long long tot = powder(x, a >> 1, P);     tot = (tot * tot) % P;     if (a & 1) tot = (tot * x) % P;     return tot;   }   inline long long num(char ch) {     return ( 0  <= ch && ch <=  9 )                ? (ch -  0 )                : (( a  <= ch && ch <=  z ) ? (ch -  a  + 10) : (ch -  A  + 36));   }   void pre(int n) {     long long c = 62, nn1 = powder(c, P1 - 2, P1), nn2 = powder(c, P2 - 2, P2);     if (nn1 * 62 % P1 != 1 || nn2 * 62 % P2 != 1) printf( Sfsf n );     mi1[0] = 1;     for (int i = 1; i <= n; i++) {       mi1[i] = (mi1[i - 1] * c) % P1;       if (mi1[i] < 0)         while (1) mi1[-154151564];     }     mi2[0] = 1;     for (int i = 1; i <= n; i++) {       mi2[i] = (mi2[i - 1] * c) % P2;       if (mi2[i] < 0)         while (1) mi2[-134564522];     }     ni1[0] = 1;     for (int i = 1; i <= n; i++) ni1[i] = ni1[i - 1] * nn1 % P1;     ni2[0] = 1;     for (int i = 1; i <= n; i++) ni2[i] = ni2[i - 1] * nn2 % P2;   }   int main() {     pre(1000000);     int n;     scanf( %d , &n);     int totlen = 0;     for (int i = 1; i <= n; i++) {       scanf( %s , st + 1);       int l = strlen(st + 1);       int pos = 0;       long long c = 62;       long long sh1 = 0, sh2 = 0;       for (int j = 1; j <= l && j <= totlen; j++) {         sh1 = (sh1 * c + num(st[j])) % P1;         sh2 = (sh2 * c + num(st[j])) % P2;         if (sh1 < 0 || sh2 < 0)           while (1) putchar(  n );         if ((s1[totlen] - s1[totlen - j] * mi1[j] % P1 + P1) % P1 == sh1 &&             (s2[totlen] - s2[totlen - j] * mi2[j] % P2 + P2) % P2 == sh2)           pos = j;       }       for (int j = pos + 1; j <= l; j++) {         Ans[++totlen] = st[j];         s1[totlen] = (s1[totlen - 1] * c + num(Ans[totlen])) % P1;         s2[totlen] = (s2[totlen - 1] * c + num(Ans[totlen])) % P2;         if (s1[totlen] * c < 0 || s2[totlen] * c < 0)           while (1) putchar(  n );       }     }     for (int i = 1; i <= totlen; i++) putchar(Ans[i]);     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct state {     bool win;     int first, second;     state() : win(false), first(0), second(1e9){};     state(bool nwin, int nfirst, int nsecond)         : win(nwin), first(nfirst), second(nsecond){};   };   bool operator<(state a, state b) {     return !(a.win > b.win ||              a.win == b.win && (a.first > b.first ||                                 a.first == b.first && a.second < b.second));   }   vector<string> dict;   int exist(string word) {     int res = 0;     for (vector<string>::iterator(i) = (dict).begin(); (i) < (dict).end(); ++(i))       if ((*i).find(word) != string::npos) ++res;     return res;   }   int score(string word) {     if (word ==   ) return 0;     int num = exist(word), value = 0, maxvalue = 0;     if (num == 0) return -1;     for (string::iterator(i) = (word).begin(); (i) < (word).end(); ++(i)) {       value += (*i) -  a  + 1;       maxvalue = max((*i) -  a  + 1, maxvalue);     }     return value * maxvalue + num;   }   map<string, state> d;   state find(string s) {     if (score(s) == -1) return state(false, 0, 0);     if (d.find(s) != d.end()) return d[s];     state res(false, 0, 1e9);     for (int i =  a ; i <=  z ; ++i)       res = max(res, max(find(char(i) + s), find(s + char(i))));     d[s] = state(res.win ^ 1, res.second + score(s), res.first);     return d[s];   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       string s;       cin >> s;       dict.push_back(s);     }     state ans = find(  );     cout << (ans.win ?  Second n  :  First n ) << ans.second <<     << ans.first;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   char ch;   int x, y;   int dx[200001], dy[200001];   int ans;   bool check(int ans) {     if (ans > n) return true;     int i, iend = n - ans + 1;     for (i = 1; i <= iend; i++) {       int vx = dx[i - 1] + dx[n] - dx[i + ans - 1];       int vy = dy[i - 1] + dy[n] - dy[i + ans - 1];       if (abs(x - vx) + abs(y - vy) <= ans &&           !((abs(x - vx) + abs(y - vy)) & 1) ^ (ans & 1))         return true;     }     return false;   }   int main() {     cin >> n;     int i;     for (i = 1; i <= n; i++) {       cin >> ch;       dx[i] = dx[i - 1];       dy[i] = dy[i - 1];       switch (ch) {         case  U :           ++dy[i];           break;         case  D :           --dy[i];           break;         case  L :           --dx[i];           break;         case  R :           ++dx[i];           break;       }     }     cin >> x >> y;     if (n < abs(x) + abs(y) || (n & 1) ^ ((abs(x) + abs(y)) & 1)) {       cout << -1 << endl;       return 0;     }     if (dx[n] == x && dy[n] == y) {       cout << 0 << endl;       return 0;     }     for (i = 20; i >= 0; i--)       if (!check(ans | (1 << i))) ans |= 1 << i;     cout << ans + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i;     cin >> n;     int a[n];     for (i = 0; i < n; i++) cin >> a[i];     vector<int> b;     for (i = 0; i < n; i++) {       if (a[i] <= 1e6 - a[i])         b.push_back(a[i] - 1);       else         b.push_back(1e6 - a[i]);     }     sort(b.begin(), b.end());     cout << b[b.size() - 1];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char a[150], b[150];     int c, d, e, f, g, x, y, z;     gets(a);     gets(b);     c = strlen(a);     for (x = 0; x < c; x++) {       if (a[x] >=  A  && a[x] <=  Z ) a[x] = a[x] + ( a  -  A );       if (b[x] >=  A  && b[x] <=  Z ) b[x] = b[x] + ( a  -  A );     }     if (strcmp(a, b) == 0)       cout <<  0  << endl;     else if (strcmp(a, b) > 0)       cout <<  1  << endl;     else       cout <<  -1  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAX = 1e5 + 5;   const long long inf = 1e18 + 9;   pair<long long, long long> dp[MAX];   long long p[MAX];   bool portal[MAX];   struct Edge {     long long from, to, cost;   };   long long Find(long long u) {     if (p[u] != u) p[u] = Find(p[u]);     return p[u];   }   void Union(long long u, long long v) { p[Find(u)] = Find(v); }   bool cmp(Edge e1, Edge e2) { return e1.cost < e2.cost; }   vector<Edge> E;   vector<pair<long long, long long> > P[MAX];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     for (long long i = 1; i <= n; i++) p[i] = i;     for (long long i = 1; i <= m; i++) {       long long a, b, c;       cin >> a >> b >> c;       P[a].push_back(make_pair(b, c));       P[b].push_back(make_pair(a, c));       E.push_back({a, b, c});     }     long long k;     cin >> k;     priority_queue<pair<long long, long long> > Q;     for (long long i = 1; i <= n; i++) dp[i] = {inf, -1};     for (long long i = 1; i <= k; i++) {       long long a;       cin >> a;       dp[a] = {0, a};       portal[a] = true;       Q.push(make_pair(-dp[a].first, a));     }     while (!Q.empty()) {       pair<long long, long long> akt = Q.top();       Q.pop();       akt.first *= -1;       if (akt.first != dp[akt.second].first) continue;       for (auto it : P[akt.second]) {         if (it.second + akt.first < dp[it.first].first) {           dp[it.first].first = it.second + akt.first;           dp[it.first].second = dp[akt.second].second;           Q.push(make_pair(-dp[it.first].first, it.first));         }       }     }     for (long long i = 0; i < E.size(); i++) {       E[i].cost += dp[E[i].from].first + dp[E[i].to].first;       E[i].from = dp[E[i].from].second;       E[i].to = dp[E[i].to].second;     }     sort(E.begin(), E.end(), cmp);     long long ans = 0;     for (auto it : E) {       if (Find(it.from) != Find(it.to)) {         Union(it.from, it.to);         ans += it.cost;       }     }     if (!portal[1]) ans += dp[1].first;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   const int maxn = 1e5 + 7;   int n, m;   long long h[maxn], p[maxn];   bool ok(long long x) {     long long cnt = 0;     for (int i = 0; i < n; i++) {       if (p[cnt] >= h[i]) {         for (int j = cnt; j < m; j++) {           if (h[i] + x >= p[j])             cnt++;           else             break;         }       } else {         if (h[i] - p[cnt] > x) continue;         long long t = max(x - (h[i] - p[cnt]) * 2, (x - (h[i] - p[cnt])) / 2);         for (int j = cnt; j < m; j++) {           if (h[i] + t >= p[j])             cnt++;           else             break;         }       }     }     if (cnt >= m)       return true;     else       return false;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> h[i];     for (int i = 0; i < m; i++) cin >> p[i];     long long l = 0, r = 100000000000 + 7;     ;     while (l + 1 < r) {       long long m = (l + r) >> 1;       if (ok(m))         r = m;       else         l = m;     }     if (ok(l)) r = l;     cout << r << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 31;   int dp[MAXN][MAXN][MAXN * MAXN];   int F(int n, int m, int k) {     if (n > m) swap(n, m);     if (k < 0) return (1 << 30);     if (dp[n][m][k] != -1) return dp[n][m][k];     if (n * m == k || k == 0) return dp[n][m][k] = 0;     int p = 1 << 30, q = 1 << 30;     for (int i = 1; i < n; i++)       p = min(p, m * m + min(F(i, m, k - m * (n - i)), F(i, m, k)));     for (int i = 1; i < m; i++)       q = min(q, n * n + min(F(n, i, k - n * (m - i)), F(n, i, k)));     return dp[n][m][k] = min(p, q);   }   int main() {     int n, m, k, q;     memset(dp, -1, sizeof dp);     scanf( %d , &q);     while (q--) {       scanf( %d %d %d , &n, &m, &k);       printf( %d n , F(n, m, k));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dir[5][2] = {0, 1, 0, -1, 1, 0, -1, 0, 0, 0};   const int inf = 0x7fffffff;   const int mod = 1000000;   const int Max = 1000000;   int temp[10], ans[Max];   void check(char *s) {     int index = 0, dec, sum = 0, cnt = 0;     dec = atoi(s);     memset(temp, 0, sizeof(temp));     for (int i = 0; i < strlen(s); ++i) sum += s[i];     for (int i = max((dec - sum), 0); i <= dec; ++i) {       int temp = i, t = i;       while (temp) {         t += (temp % 10);         temp /= 10;       }       if (t == dec) {         ans[cnt++] = i;       }     }     printf( %d n , cnt);     for (int i = 0; i < cnt; ++i) {       printf( %d%c , ans[i], i == cnt - 1 ?   n  :    );     }   }   int main() {     char num[10];     scanf( %s , num);     check(num);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     string s;     cin >> s;     int n = s.size();     if (n == 1) {       cout << 0;       return 0;     }     int ans = 0;     int co = 1;     vector<pair<char, int> > c;     for (int i = 1; i < n; i++) {       if (s[i] != s[i - 1]) {         c.emplace_back(s[i - 1], co);         co = 0;       }       co++;     }     c.emplace_back(s[n - 1], co);     int k = c.size();     if (k % 2 == 0) {       cout << 0;       return 0;     }     for (int i = 0; i < k / 2; i++) {       if ((c[i].first != c[k - 1 - i].first) ||           (c[i].second + c[k - 1 - i].second < 3)) {         cout << 0;         return 0;       }     }     if (c[k / 2].second == 1)       cout << 0 << endl;     else       cout << c[k / 2].second + 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int blocksize;   int msmo7;   struct query {     int start, en, idxofquery, blockidx, mincolor;     query() {}     query(int l, int r, int i, int adeh) {       start = l;       en = r;       idxofquery = i;       blockidx = l / blocksize;       mincolor = adeh;     }     bool operator<(const query& q) const {       if (start / blocksize != q.start / blocksize)         return start / blocksize < q.start / blocksize;       else         return en < q.en;     }   };   query queries[100005];   vector<int> arr[100005];   int subtree[100005];   int idxinorder[100005];   int treearray[100005];   int color[100005];   int ansforquery;   int answers[100005];   int bit[100010];   int freq[100005];   const int maxn = 1e5 + 5;   void update(int idx, int val) {     for (; idx <= maxn; idx += (idx & -idx)) bit[idx] += val;   }   int getsum(int idx) {     int sum = 0;     for (; idx; idx -= (idx & -idx)) sum += bit[idx];     return sum;   }   int nid = 0;   void dfs(int s, int parent) {     subtree[s] = 1;     treearray[nid++] = s;     idxinorder[s] = nid - 1;     for (int i = 0; i < arr[s].size(); ++i) {       int to = arr[s][i];       if (to != parent) {         dfs(to, s);         subtree[s] += subtree[to];       }     }   }   void add(int valueofpos) {     update(maxn - freq[color[valueofpos]]++, -1);     update(maxn - freq[color[valueofpos]], 1);   }   void rem(int valueofpos) {     update(maxn - freq[color[valueofpos]]--, -1);     update(maxn - freq[color[valueofpos]], 1);   }   int main() {     int n, m;     scanf( %d , &n);     scanf( %d , &m);     for (int i = 1; i <= n; ++i) scanf( %d , &color[i]);     int u, v;     for (int i = 1; i < n; ++i) {       scanf( %d , &u);       scanf( %d , &v);       arr[u].push_back(v);       arr[v].push_back(u);     }     dfs(1, -1);     blocksize = sqrt(n);     int k;     for (int i = 0; i < m; ++i) {       scanf( %d , &v);       scanf( %d , &k);       queries[i].start = idxinorder[v];       queries[i].en = queries[i].start + subtree[v] - 1;       queries[i].idxofquery = i;       queries[i].mincolor = k;     }     sort(queries, queries + m);     int curl = 0;     int curr = -1;     for (int i = 0; i < m; ++i) {       query& qu = queries[i];       while (curl > qu.start) add(treearray[--curl]);       while (curr < qu.en) add(treearray[++curr]);       while (curl < qu.start) rem(treearray[curl++]);       while (curr > qu.en) rem(treearray[curr--]);       answers[qu.idxofquery] = getsum(maxn - qu.mincolor);     }     for (int i = 0; i < m; ++i) printf( %d n , answers[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string q;     cin >> q;     int n;     cin >> n;     vector<string> m(n);     for (int i = 0; i < (n); ++i) cin >> m[i];     sort(m.begin(), m.end());     for (int i = 0; i < (n); ++i) {       if (m[i].size() < q.size()) continue;       if (m[i].substr(0, q.size()) == q) {         cout << m[i] << endl;         return 0;       }     }     cout << q << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, u, v;   vector<int> arr[100001];   long double ans = 0.0;   long long int siz[100001]{0};   void dfs(int to, int from, int val) {     int ret = 1;     ans += 1.0 / val;     for (auto i : arr[to]) {       if (i != from) {         dfs(i, to, val + 1);         siz[to] += siz[i];       }     }   }   void pre() {}   void solve() {     cin >> n;     for (int i = 0; i < n - 1; i++) {       cin >> u >> v;       arr[u].push_back(v);       arr[v].push_back(u);     }     dfs(1, 0, 1);     cout << setprecision(26) << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     pre();     solve();   }
#include <bits/stdc++.h>   using namespace std;   struct node {     long long v, p, id;   } t[2000001];   bool cmp2(node a, node b) { return a.p < b.p; }   struct cmp {     bool operator()(node a, node b) { return a.v > b.v; }   };   priority_queue<node, vector<node>, cmp> q;   priority_queue<long long> q2;   long long vis[2000001];   signed main() {     long long T;     scanf( %I64d , &T);     while (T--) {       long long n;       scanf( %I64d , &n);       for (long long i = 1; i <= n; i++) vis[i] = 0;       while (!q.empty()) q.pop();       while (!q2.empty()) q2.pop();       for (long long i = 1; i <= n; i++) {         scanf( %I64d%I64d , &t[i].p, &t[i].v);         t[i].id = i;         q.push(t[i]);       }       sort(t + 1, t + n + 1, cmp2);       long long cur = 0, ans = 0;       for (long long i = 1; i <= n; i++) {         while (cur != n && cur < t[i].p) {           while (vis[q.top().id] == 1) q.pop();           if (q2.size()) {             ans += q.top().v - q2.top();             q2.pop();             vis[q.top().id] = 1;             q.pop();           } else {             ans += q.top().v;             vis[q.top().id] = 1;             q.pop();           }           cur++;         }         if (cur == n) break;         if (vis[t[i].id])           q2.push(t[i].v);         else           ++cur;         vis[t[i].id] = 1;       }       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mn = 1000001;   bool shirt(int p, int s) {     int i = (s / 50) % 475;     for (int j = 0; j < 25; j++) {       i = (i * 96 + 42) % 475;       if ((26 + i) == p) return true;     }     return false;   }   int main() {     int p, x, y;     cin >> p >> x >> y;     int al = 0, temp = x;     while (1 && temp >= y) {       if (shirt(p, temp)) {         cout << 0 << endl;         return 0;       }       temp -= 50;     }     int ah = 0;     temp = x;     while (1) {       if (shirt(p, temp)) break;       if ((temp - 50) >= y) {         if (shirt(p, temp - 50)) break;       }       temp += 100;       ah++;     }     int v = temp - x;     int ans = v / 100;     cout << ah << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long solve() {     string x[12] = { C ,   C# ,  D ,   D# ,  E ,  F ,                      F# ,  G ,   G# ,  A ,   B ,  H };     map<string, long long> m;     for (long long i = 0; i < 12; ++i) {       m[x[i]] = i;     }     long long q[3];     string a, b, c;     cin >> a >> b >> c;     q[0] = m[a];     q[1] = m[b];     q[2] = m[c];     sort(q, q + 3);     do {       if ((q[0] + 4) % 12 == q[1] % 12 && (q[1] + 3) % 12 == q[2] % 12) {         cout <<  major ;         return 0;       }       if ((q[0] + 3) % 12 == q[1] % 12 && (q[1] + 4) % 12 == q[2] % 12) {         cout <<  minor ;         return 0;       }     } while (next_permutation(q, q + 3));     cout <<  strange ;   }   signed main() {     ios::sync_with_stdio(false);     long long t = 1;     while (t--) solve();     return 0;   }