malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   short memo[6][40][1 << 6][1 << 6][1 << 6];   int n, m;   short roll(int row, int col, int a, int b, int c) {     if (col == m) {       return (n - __builtin_popcount(a));     }     if (row == n) {       return roll(0, col + 1, b, c, 0) +              (col > 0 ? (n - __builtin_popcount(a)) : 0);     }     short &ans = memo[row][col][a][b][c];     if (~ans) {       return ans;     }     ans = roll(row + 1, col, a, b | (1 << row), c);     if (col > 0) {       ans = max(ans, roll(row + 1, col, a | (1 << row), b, c));     }     if (col < m - 1) {       ans = max(ans, roll(row + 1, col, a, b, c | (1 << row)));     }     if (row > 0) {       ans = max(ans, roll(row + 1, col, a, b | (1 << (row - 1)), c));     }     if (row < n - 1) {       ans = max(ans, roll(row + 1, col, a, b | (1 << (row + 1)), c));     }     return ans;   }   int main() {     scanf( %d %d , &n, &m);     if (n > m) {       swap(n, m);     }     memset(memo, -1, sizeof memo);     cout << roll(0, 0, 0, 0, 0) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int modulo = 1e9 + 7;   const int max_n = 111;   const int max_k = max_n * max_n;   int bin_pow(int base, long long pw) {     if (pw == 0) return 1;     if (pw & 1) return (1LL * base * bin_pow(base, pw - 1)) % modulo;     return bin_pow((1LL * base * base) % modulo, pw >> 1);   }   int a[max_n][max_k], C[max_n][max_n], d[max_n][max_n];   int n, k;   long long m;   int main() {     ios_base::sync_with_stdio(false);     C[0][0] = 1;     for (int i = 1; i < max_n; ++i) {       C[0][i] = 0;       C[i][0] = 1;     }     for (int i = 1; i < max_n; ++i)       for (int j = 1; j < max_n; ++j)         C[i][j] = (0LL + C[i][j] + C[i - 1][j] + C[i - 1][j - 1]) % modulo;     cin >> n >> m >> k;     for (int i = 1; i <= n; ++i)       for (int j = 0; j <= n; ++j) {         long long pw = 1 + (m - i) / n;         d[i][j] = bin_pow(C[n][j], pw);       }     a[0][0] = 1;     for (int i = 1; i <= n; ++i)       for (int j = 0; j <= min(k, i * n); ++j)         for (int t = 0; t <= min(j, n); ++t)           if (a[i - 1][j - t] != 0)             a[i][j] = (a[i][j] + 1LL * a[i - 1][j - t] * d[i][t]) % modulo;     cout << a[n][k] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cube[8][3];   long long len[28];   long long dist(int a, int b) {     long long ret = 0;     for (int i = 0; i < 3; i++)       ret += (long long)(cube[a][i] - cube[b][i]) * (cube[a][i] - cube[b][i]);     return ret;   }   bool check() {     int idx = 0;     for (int i = 0; i < 8; i++)       for (int j = i + 1; j < 8; j++) len[idx++] = dist(i, j);     sort(len, len + 28);     for (int i = 1; i < 12; i++)       if (len[i] != len[i - 1] || len[i] == 0) return false;     for (int i = 13; i < 24; i++)       if (len[i] != len[i - 1]) return false;     for (int i = 25; i < 28; i++)       if (len[i] != len[i - 1]) return false;     if (len[0] * 2 != len[12] || len[0] * 3 != len[24]) return false;     return true;   }   bool go(int idx) {     if (idx == 8) return check();     do {       if (go(idx + 1)) return true;     } while (next_permutation(cube[idx], cube[idx] + 3));     return false;   }   int main() {     for (int i = 0; i < 8; i++) cin >> cube[i][0] >> cube[i][1] >> cube[i][2];     for (int i = 0; i < 8; i++) sort(cube[i], cube[i] + 3);     if (go(1)) {       cout <<  YES n ;       for (int i = 0; i < 8; i++)         cout << cube[i][0] <<     << cube[i][1] <<     << cube[i][2] <<   n ;       return 0;     }     cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i;     cin >> n;     bool t[2 * n], s[2 * n];     char tmp;     for (i = 0; i < 2 * n; i++) {       cin >> tmp;       t[i] = (tmp ==  1 );     }     for (i = 0; i < 2 * n; i++) {       cin >> tmp;       s[i] = (tmp ==  1 );     }     int t_sum = 0, s_sum = 0, and_sum = 0, t_sum1 = 0, s_sum1 = 0;     for (i = 0; i < 2 * n; i++) {       t_sum += int(t[i]);       s_sum += int(s[i]);       and_sum += int(t[i] & s[i]);       t_sum1 += int(!t[i] & s[i]);       s_sum1 += int(t[i] & !s[i]);     }     if (t_sum > s_sum) {       if (and_sum % 2 == 0)         t_sum -= min(t_sum - s_sum, s_sum1) / 2;       else         t_sum -= min(t_sum - s_sum, s_sum1) / 2 + min(t_sum - s_sum, s_sum1) % 2;     } else if (t_sum < s_sum) {       if (and_sum % 2 == 0)         s_sum -= min(s_sum - t_sum, t_sum1) / 2 + min(s_sum - t_sum, t_sum1) % 2;       else         s_sum -= min(s_sum - t_sum, t_sum1) / 2;     }     t_sum -= and_sum / 2;     s_sum -= and_sum / 2 + and_sum % 2;     if (t_sum == s_sum)       cout <<  Draw ;     else if (t_sum > s_sum)       cout <<  First ;     else       cout <<  Second ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   int v[N], ans[N];   int main() {     cin.tie(0), ios_base::sync_with_stdio(false);     int n, k, s = 0;     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> v[i], s += v[i], ans[i % k] += v[i];     int tans = 0;     for (int i = 0; i < k; i++) tans = max(tans, abs(s - ans[i]));     cout << tans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const long long int MXN = 1e18;   struct node {     double x, y;   } p, p1, p2, p3, p4;   double ji(node a, node b, node c) {     return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);   }   bool jug(node a) {     if ((ji(p1, p2, a) * ji(p3, p4, a) >= 0) &&         (ji(p2, p3, a) * ji(p4, p1, a) >= 0))       return true;     return false;   }   int main() {     int n, d, m;     cin >> n >> d >> m;     p1.x = 0, p1.y = d;     p2.x = d, p2.y = 0;     p3.x = n, p3.y = n - d;     p4.x = n - d, p4.y = n;     int ans = 0;     double a, b;     for (int i = 0; i < m; i++) {       cin >> p.x >> p.y;       if (jug(p)) {         cout <<  YES  << endl;       } else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int a, b, c;       cin >> a >> b >> c;       int totmake = (a + b + c) / 3;       if (a == 0 || b == 0 || totmake == 0) {         cout << 0 << endl;       } else if (a <= b && a <= totmake) {         cout << a << endl;       } else if (b <= a && b <= totmake) {         cout << b << endl;       } else {         cout << totmake << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, t;     cin >> s >> t;     map<char, char> m;     bool ans = true;     vector<pair<char, char>> v;     int count = 0;     for (int i = 0; i < s.size(); i++) {       if (m.find(s[i]) != m.end()) {         if (m[s[i]] != t[i]) {           ans = false;           break;         } else {           continue;         }       } else {         if (m.find(t[i]) != m.end()) {           ans = false;           break;         } else {           m[s[i]] = t[i];           m[t[i]] = s[i];           if (s[i] != t[i]) {             v.push_back({s[i], t[i]});             count++;           }         }       }     }     if (ans) {       cout << count << endl;       for (int i = 0; i < count; i++)         cout << v[i].first <<     << v[i].second << endl;     } else       cout <<  -1 ;     return 0;   }
# include <bits/stdc++.h>   using namespace std;   const int N=1e3+10;   int n,m,a[N][N],sum1[N],sum2[N],c1[N],c2[N],c3[N];   map<int,int>mp,tt;   signed main()   {    scanf( %d%d ,&n,&m);    for (int i=1;i<=m;i++)      for (int j=1;j<=n;j++) {      scanf( %d ,&a[i][j]);      sum1[i]+=a[i][j];      sum2[i]+=a[i][j]*a[i][j];     }     for (int i=1;i<=m;i++) {     c1[i]=sum1[i]-sum1[i-1];     c2[i]=sum2[i]-sum2[i-1];     if (i>1) mp[c1[i]]++,tt[c1[i]]=i;    }    int id=m;    for (map<int,int>::iterator it=mp.begin();it!=mp.end();it++) {     if ((it->second)==1) id=min(id,tt[it->first]);    }    for (int i=1;i<=m;i++) c3[i]=c2[i]-c2[i-1];    int res;    if (id>=4) res=c3[3]; else res=c3[7];         if (id!=2) {     for (int i=3;i<=m;i++) c3[i]=res;     for (int i=1;i<=m;i++) c3[i]=c3[i-1]+c3[i];     for (int i=1;i<=m;i++) c3[i]=c3[i-1]+c3[i];    } else {     int d=sum2[m]-sum2[m-1]-sum2[m-1]+sum2[m-2];     c3[m]=sum2[m]-sum2[m-1];     for (int i=m-1;i>=2;i--) c3[i]=c3[i+1]-d;     for (int i=1;i<=m;i++) c3[i]=c3[i-1]+c3[i];    }    if (id>=4) res=c1[3]; else res=c1[7];    if (id!=2) {     for (int i=3;i<=m;i++) c1[i]=res;     for (int i=1;i<=m;i++) c1[i]=c1[i-1]+c1[i];    } else {     int d=sum1[m]-sum1[m-1]-sum1[m-1]+sum1[m-2];     c1[m]=sum1[m]-sum1[m-1];     for (int i=m-1;i>=2;i--) c1[i]=c1[i+1]-d;     for (int i=1;i<=m;i++) c1[i]=c1[i-1]+c1[i];    }    int ans1=id-1,ans2;    for (int i=1;i<=n;i++) {     int t=c1[id]-(sum1[id]-a[id][i]);     if (t*t+sum2[id]-a[id][i]*a[id][i]==c3[id]) {      ans2=t; break;     }    }    printf( %d %d n ,ans1,ans2);    fflush(stdout);    return 0;   }      /*   by maystern   */
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, s1, s2;     long long a, b, c = 0;     cin >> s;     b = stoi(s);     while (b > 0) {       s1 = s;       sort(s1.begin(), s1.end());       int d = stoi(s1) % 10;       b = b - d;       c++;       s = to_string(b);     }     cout << c <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a0, a1, a2, b0, b1, b2, n;     cin >> a0 >> a1 >> a2;     int cnt = (a0 + a1 + a2) / 5;     if ((a0 + a1 + a2) % 5) cnt++;     cin >> b0 >> b1 >> b2;     cnt += ((b0 + b1 + b2) / 10);     if ((b0 + b1 + b2) % 10) cnt++;     cin >> n;     if (cnt <= n)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x, y;   string tt(long long a) {     string ans =   ;     while (a != 0) ans += (a % 10) +  0 , a /= 10;     int p = ans.length();     for (int i = 0; i * 2 < p; ++i) swap(ans[i], ans[p - i - 1]);     return ans;   }   int main() {     cin >> x >> y;     string s;     while (x != 1 || y != 1) {       if (x < y) {         s += tt((y - 1) / x) +  B ;         y = (y - 1) % x + 1;       } else if (x > y) {         s += tt((x - 1) / y) +  A ;         x = (x - 1) % y + 1;       } else {         cout <<  Impossible n ;         return 0;       }     }     cout << s <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double Cnk(int n, int k) {     double result = 1;     for (int i = 1; i <= k; ++i) {       result *= n - k + i;       result /= i;     }     return result;   }   double Power(int n, int power) {     double result = 1;     for (int i = 0; i < power; ++i) {       result *= n;     }     return result;   }   int main() {     int n, m;     cin >> n >> m;     vector<int> a(m);     for (int i = 0; i < m; ++i) {       cin >> a[i];     }     vector<vector<vector<double> > > p(n + 1);     for (int i = 0; i <= n; ++i) {       p[i].resize(m + 1);       for (int j = 0; j <= m; ++j) {         p[i][j].assign(n + 1, 0);       }     }     for (int j = 0; j <= m; ++j) {       p[0][j][0] = 1;       for (int i = 1; i <= n; ++i) {         p[0][j][i] = 0;         p[i][j][0] = 0;       }     }     for (int i = 0; i <= n; ++i) {       for (int k = 0; k <= n; ++k) {         if (k == (i + a[0] - 1) / a[0]) {           p[i][1][k] = 1;         } else {           p[i][1][k] = 0;         }       }     }     for (int j = 2; j <= m; ++j) {       for (int i = 1; i <= n; ++i) {         for (int k = 1; k <= n; ++k) {           p[i][j][k] = 0;           for (int h = a[j - 1] * k - a[j - 1] + 1;                (h <= i) && (h < a[j - 1] * (k + 1) - a[j - 1] + 1); ++h) {             double sum = 0;             for (int l = 0; l <= k; ++l) {               sum += p[i - h][j - 1][l];             }             p[i][j][k] += Cnk(i, h) * Power(j - 1, i - h) * sum;           }           for (int h = 0; (h <= i) && (h < k * a[j - 1] - a[j - 1] + 1); ++h) {             p[i][j][k] += Cnk(i, h) * Power(j - 1, i - h) * p[i - h][j - 1][k];           }           p[i][j][k] /= Power(j, i);         }       }     }     double E = 0;     for (int i = 0; i <= n; ++i) {       E += i * p[n][m][i];     }     printf( %.10lf , E);     getchar();     getchar();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ull = unsigned long long;   int main() {     int t;     cin >> t;     while (t--) {       ull n, k, x;       cin >> n >> k >> x;       cin.ignore();       string arr;       getline(cin, arr);       vector<pair<ull, ull>> values;       for (int i = arr.size(); i-- > 0;) {         if (arr[i] ==  a ) {           if (i == arr.size() - 1 || arr[i + 1] !=  a )             values.emplace_back(0, 1);           else             values.back().second++;           continue;         }         if (i == arr.size() - 1)           values.emplace_back(1, k);         else if (arr[i + 1] ==  * )           values.back().second += k;         else           values.emplace_back(1, k);       }       x--;       for (int i = values.size(); i-- > 0;) {         if (values[i].first == 0) {           for (int j = 0; j < values[i].second; j++) cout <<  a ;           continue;         }         ull weight = 1;         for (int j = 0; j < values.size(); j++) {           if (j == i) break;           if (!values[j].first) continue;           ull temp = weight * (values[j].second + 1);           if (temp < weight) {             weight = 0;             break;           }           weight = temp;         }         if (!weight) continue;         int total_b = x / weight;         for (int j = 0; j < total_b; j++) cout <<  b ;         x -= total_b * weight;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1000000007;   const int MM = 998244353;   template <typename T, typename U>   static inline void amin(T &x, U y) {     if (y < x) x = y;   }   template <typename T, typename U>   static inline void amax(T &x, U y) {     if (x < y) x = y;   }   int _runtimeTerror_() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     sort(a.begin(), a.end());     string s;     cin >> s;     vector<int> ans(n + 1);     vector<char> dir(n);     dir[0] = s[0];     ans[0] = 0;     char heavy = s[0];     for (int i = 1; i < n; ++i) {       if (s[i] == heavy) {         if (i & 1) {           dir[i] =  L  ^  R  ^ heavy;           ans[i] += 0;           ++ans[0];           --ans[i];         } else {           dir[i] = heavy;           ans[i] += 0;           ++ans[0];           --ans[i];         }       } else {         ans[i] += i;         dir[i] = s[i];         ans[i + 1] -= i;       }       heavy = s[i];     }     for (int i = 1; i < n; ++i) {       ans[i] += ans[i - 1];     }     for (int i = 0; i < n; ++i) {       cout << a[ans[i]] <<     << dir[i] <<   n ;     }     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int TESTS = 1;     while (TESTS--) _runtimeTerror_();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, i, j, k, l, m, b, t, sum, sum1, flag, max1, min1;     cin >> n >> m;     long long a[n + 1];     for (i = 1; i <= n; i++) {       cin >> a[i];     }     sum = 0;     long long pre[100009];     pre[1] = a[1];     for (i = 2; i <= n; i++) {       pre[i] = pre[i - 1] + a[i];     }     max1 = INT_MIN;     for (i = 1; i <= n; i++) {       k = pre[i];       l = pre[n] - pre[i];       k = k % m;       l = l % m;       max1 = max(k + l, max1);     }     cout << max1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   template <class T>   void out(T x) {     if (x < 0) {       putchar( - );       x = -x;     }     if (x > 9) out(x / 10);     putchar(x % 10 +  0 );   }   long long dp[2005];   struct node {     int x, y;   } a[2005];   bool cmp(node a, node b) {     if (a.x == b.x) return a.y < b.y;     return a.x < b.x;   }   long long fact[200010], inv[200010];   inline long long MOD(long long x) {     while (x < 0) x += mod;     return x % mod;   }   long long binpow(long long a, int k) {     if (k == 0) return 1;     long long ans = binpow(a, k / 2);     ans = 1ll * ans * ans % mod;     if (k % 2) ans = 1ll * ans * a % mod;     return ans;   }   long long C(long long n, long long k) {     if (k > n) return 0;     long long ans = fact[n] * 1ll * inv[k] % mod;     ans = 1ll * ans * inv[n - k] % mod;     return ans % mod;   }   void pre() {     fact[0] = inv[0] = 1;     for (int i = 1; i < 200010; i++) {       fact[i] = 1ll * i * fact[i - 1] % mod;       inv[i] = binpow(fact[i], mod - 2);     }   }   int main() {     pre();     int h, w, n;     scanf( %d%d%d , &h, &w, &n);     for (int i = 0; i < n; i++) scanf( %d%d , &a[i].x, &a[i].y);     sort(a, a + n, cmp);     long long ans = C(h + w - 2, h - 1);     for (int i = 0; i < n; i++) {       dp[i] = C(a[i].x + a[i].y - 2, a[i].y - 1);       for (int j = 0; j < i; j++)         if (a[j].x <= a[i].x && a[j].y <= a[i].y) {           dp[i] = (dp[i] -                    dp[j] * C(a[i].x - a[j].x + a[i].y - a[j].y, a[i].x - a[j].x) +                    mod) %                   mod;         }       ans = (ans - dp[i] * C(h - a[i].x + w - a[i].y, h - a[i].x) + mod) % mod;     }     out((ans + mod) % mod);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int>> adj[101];   int vis[101][101];   int id;   bool dfs(const int &idx, int cur, int to) {     if (cur == to) return true;     bool ret = false;     for (int i = 0; i < (int)adj[idx][cur].size(); i++) {       if (vis[idx][adj[idx][cur][i]] == id) continue;       vis[idx][adj[idx][cur][i]] = id;       ret |= dfs(idx, adj[idx][cur][i], to);     }     return ret;   }   int main() {     int n, m, q;     scanf( %d%d , &n, &m);     for (int i = 0; i < 101; i++) adj[i].resize(n);     for (int i = 0, u, v, c; i < m; i++) {       scanf( %d%d%d , &u, &v, &c);       adj[c - 1][u - 1].push_back(v - 1);       adj[c - 1][v - 1].push_back(u - 1);     }     int u, v;     scanf( %d , &q);     while (q--) {       id++;       scanf( %d%d , &u, &v);       int ans = 0;       for (int i = 0; i < m; i++) ans += dfs(i, u - 1, v - 1);       printf( %d n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 1e5 + 7;   int H, ans;   int cnt[10007][444], a[Maxn], flag[Maxn];   int mark[Maxn];   vector<int> luck;   void lucky(int p) {     if (p > 10000) return;     luck.push_back(p);     mark[p] = true;     p *= 10;     lucky(p + 4);     lucky(p + 7);   }   void add(int l, int r, int d) {     int p1 = l / H;     int p2 = r / H;     for (int i = p1 + 1; i < p2; i++) flag[i] += d;     if (p1 == p2) {       for (int i = l; i <= r; i++) cnt[a[i]][p1]--, a[i] += d, cnt[a[i]][p1]++;       return;     }     int L = p2 * H;     int R = p1 * H + H - 1;     for (int i = L; i <= r; i++) cnt[a[i]][p2]--, a[i] += d, cnt[a[i]][p2]++;     for (int i = l; i <= R; i++) cnt[a[i]][p1]--, a[i] += d, cnt[a[i]][p1]++;   }   void Find(int l, int r) {     int p1 = l / H;     int p2 = r / H;     for (int i = p1 + 1; i < p2; i++)       for (int j = 0; j < luck.size(); j++)         if (luck[j] - flag[i] > 0) ans += cnt[luck[j] - flag[i]][i];     if (p1 == p2) {       for (int i = l; i <= r; i++) ans += mark[a[i] + flag[p1]];       return;     }     int L = p2 * H;     int R = p1 * H + H - 1;     for (int i = L; i <= r; i++) ans += mark[a[i] + flag[p2]];     for (int i = l; i <= R; i++) ans += mark[a[i] + flag[p1]];   }   int main() {     int n, q;     scanf( %d%d , &n, &q);     H = sqrt(n);     for (int i = 0; i < n; i++) scanf( %d , a + i), cnt[a[i]][i / H]++;     lucky(4);     lucky(7);     for (int i = 0; i < q; i++) {       char s[10];       scanf( %s  , s);       int l, r, x;       if (s[0] ==  c ) {         ans = 0;         scanf( %d%d , &l, &r);         l--, r--;         Find(l, r);         printf( %d  , ans);       } else {         scanf( %d%d%d , &l, &r, &x);         l--, r--;         add(l, r, x);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   char img[2007][2007];   int c[2007], r[2007];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) scanf( %s , img[i]);     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) img[i][j] -=  0 ;     int ans = 0;     for (int i = 0; i < n; i++)       for (int j = n - 1; j > i; --j)         if (c[j] ^ r[i] ^ img[i][j]) {           ++ans;           c[j] ^= 1, r[i] ^= 1;         }     for (int i = 0; i < n; i++) img[i][i] ^= c[i] ^ r[i];     memset(c, 0, sizeof(c)), memset(r, 0, sizeof(r));     for (int i = n - 1; i >= 0; --i)       for (int j = 0; j < i + 1; j++)         if (c[j] ^ r[i] ^ img[i][j]) {           ++ans;           c[j] ^= 1, r[i] ^= 1;         }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   const int maxn = 1e6 + 3000;   const long long mod = 1e9 + 7;   long long k, p;   int f[maxn];   bool vis[maxn];   long long cnt[maxn];   long long qpow(long long x, long long p) {     long long ans = 1;     while (p) {       if (p & 1) ans = ans * x % mod;       x = x * x % mod;       p >>= 1;     }     return ans;   }   int main() {     cin >> p >> k;     if (k == 0) {       cout << qpow(p, p - 1) << endl;       return 0;     }     if (k == 1) {       cout << qpow(p, p) << endl;       return 0;     }     for (int i = 1; i < p; i++) {       f[i] = i * k % p;     }     long long ans = 1;     for (int i = 1; i < p; i++) {       int c = 0;       if (vis[i]) continue;       int x = i;       while (!vis[x]) {         vis[x] = 1;         x = f[x];         c++;       }       cnt[c]++;     }     for (int i = 2; i < maxn; i++) {       if (cnt[i]) {         ans = ans * qpow(i * cnt[i] + 1, cnt[i]) % mod;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void reset(int& n, int first) { n = n & ~(1 << first); }   bool check(int n, int first) { return (bool)(n & (1 << first)); }   const int mx = 55;   long long inf = 1e18;   unsigned long long f[mx], v;   int a[mx];   int main() {     f[0] = f[1] = 1;     int i, j, k, n;     for (i = 2; i < mx; i++) f[i] = f[i - 1] + f[i - 2];     while (cin >> n >> v) {       int cur = n;       for (i = 1; i <= n; i++) a[i] = i;       for (i = 1; i <= n; i++) {         if (v > f[cur - 1]) {           swap(a[i], a[i + 1]);           i++;           cur -= 2;           v -= f[cur + 1];         } else           cur--;       }       for (i = 1; i <= n; i++) printf( %d  , a[i]);       puts(  );     }   }
#include <bits/stdc++.h>   using ll = long long;   int main() {     std::ios_base::sync_with_stdio(0);     std::cin.tie(0);     std::string s;     std::cin >> s;     int n = s.length();     std::vector<std::set<int>> adj(26);     for (int i = 0; i < n; ++i) {       int d = s[i] -  a ;       adj[d].insert(i);     }     int q;     std::cin >> q;     while (q--) {       int op;       std::cin >> op;       if (op == 1) {         int pos;         char c;         std::cin >> pos >> c;         --pos;         int d = s[pos] -  a ;         s[pos] = c;         adj[d].erase(pos);         adj[c -  a ].insert(pos);       } else {         int l, r;         std::cin >> l >> r;         --l, --r;         int ans = 0;         for (int i = 0; i < 26; ++i) {           if (adj[i].empty()) {             continue;           }           auto it = adj[i].lower_bound(l);           if (it == adj[i].end()) {             continue;           }           int index = *it;           if (index <= r) {             ++ans;           }         }         std::cout << ans <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d, i = 0, j = 0;     cin >> a >> b >> c >> d;     while (a != 0) {       a = a - 1;       i++;     }     while (b != 0) {       b = b - 1;       j++;     }     if (j >= i)       cout <<  Second ;     else       cout <<  First ;   }