malteklaes/cpp-code-code_search_net-style huggingface dataset:
///Bismillahir Rahmanir Rahim   #include<bits/stdc++.h>   #define        u64             uint64_t   #define        ll              long long   #define        endl              n    #define        PI              acos(-1)   #define        fi              first   #define        si              second   #define        mkp             make_pair   #define        pb              push_back   #define        set0(arr)       memset(arr, 0, sizeof(arr))   #define        setinf(arr)     memset(arr, 126, sizeof(arr))   #define        all(x)          (x).begin(),(x).end()   #define        sz(v)           ((ll)(v).size())   #define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)   using namespace std;   using          pll        =      pair<ll, ll> ;   using          vl         =      vector<ll> ;   using          vpll       =      vector<pll> ;   using          mll        =      map<ll, ll> ;   using          mcl        =      map<char, ll> ;   using          msl        =      map<string,ll> ;   using          sl         =      set<ll> ;   using          sc         =      set<char> ;   using          dl         =      deque<ll> ;   const int N = 1e6+5 ;      ll      mod = 1e9+7 ;   vl      adj[N] ;   vpll    adjc[N] ;   ll      vis[N] ;   ll      arr[N] ;      ll sumd(ll a,ll b){return (((a%mod)+(b%mod))%mod);}   ll muld(ll a,ll b){return (((a%mod)*(b%mod))%mod);}   ll subd(ll a,ll b){return (((a%mod)-(b%mod)+mod)%mod);}            int main()   {       IOS;       ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18, cs;       string   str ;       char     ch ;       double   db ;       ll       l, r ;       //code          cin>>tc;       for(cs=1;cs<=tc;cs++)       {           ll c1,c2,c3,a1,a2,a3,a4,a5;           cin>>c1>>c2>>c3;           cin>>a1>>a2>>a3>>a4>>a5;           c1-=a1;           c2-=a2;           c3-=a3;           if(c1<0||c2<0||c3<0)           {                  cout<< NO n ;continue;           }           if(c1>=a4)           {                          if(c2>=a5){}                          else                          {                              a5-=c2;                              c3-=a5;                              if(c3<0)                              {                                    cout<< NO n ;continue;                              }                          }           }           else           {                  a4-=c1;                  c3-=a4;                  if(c3<0)                  {                         cout<< NO n ;continue;                  }                  else                  {                                     if(c2>=a5);                  else                 {                 a5-=c2;                 c3-=a5;                 if(c3<0)                 {                 cout<< NO n ;continue;                 }                 }                 }           }           cout<< YES n ;          }             //code       return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long pwr(long long a, long long b, long long mod) {     a %= mod;     if (a < 0) a += mod;     long long ans = 1;     while (b) {       if (b & 1) ans = (ans * a) % mod;       a = (a * a) % mod;       b /= 2;     }     return ans;   }   long long pwr(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans *= a;       a *= a;       b /= 2;     }     return ans;   }   long long gcd(long long a, long long b) {     while (b) {       long long temp = a;       a = b;       b = temp % b;     }     return a;   }   long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }   long long modularInverse(long long a, long long m) {     assert(false);     return pwr(a, m - 2, m);   }   const int mod = 1000000007;   int DP[5001][5001];   int PDP[5001][5001];   int n, k, a, b;   void generatePDP(int u) {     PDP[u][0] = DP[u][0];     for (int i = 1; i <= n; ++i) {       PDP[u][i] = (PDP[u][i - 1] + DP[u][i]) % mod;     }   }   int main() {     std::ios::sync_with_stdio(false);     cin >> n >> a >> b >> k;     for (int i = 1; i <= n; ++i) DP[0][i] = 1;     DP[0][b] = 0;     for (int i = 1; i <= k; ++i) {       generatePDP(i - 1);       for (int j = 1; j <= n; ++j) {         if (j == b) {           DP[i][b] = 0;         } else if (j < b) {           int dist = b - j;           int start = max(1, j - dist + 1);           int end = b - 1;           if (start - 1 >= 1)             DP[i][j] = PDP[i - 1][end] - PDP[i - 1][start - 1] - DP[i - 1][j];           else             DP[i][j] = PDP[i - 1][end] - DP[i - 1][j];         } else if (j > b) {           int dist = j - b;           int start = b + 1;           int end = min(j + dist - 1, n);           if (start - 1 >= 1)             DP[i][j] = PDP[i - 1][end] - PDP[i - 1][start - 1] - DP[i - 1][j];           else             DP[i][j] = PDP[i - 1][end] - DP[i - 1][j];         }         DP[i][j] %= mod;         if (DP[i][j] < 0) DP[i][j] += mod;       }     }     cout << DP[k][a] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   long long qpow(long long x, long long k) {     return k == 0 ? 1                   : 1ll * qpow(1ll * x * x % mod, k >> 1) * (k & 1 ? x : 1) % mod;   }   const int md = 1e9 + 7;   const int Maxn = 5005;   int n, k;   long long dp[Maxn][Maxn];   int main() {     scanf( %d%d , &n, &k);     dp[0][0] = 1;     for (int i = 1; i <= k; i++) {       for (int j = 1; j <= i; j++) {         dp[i][j] = (dp[i - 1][j] * j + dp[i - 1][j - 1] * (n - j + 1)) % md;       }     }     long long ans = 0;     for (int i = 1; i <= min(n, k); i++) {       ans = (ans + dp[k][i] * qpow(2, n - i)) % md;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mat[101][101];   int min(int a, int b) { return a < b ? a : b; }   int max(int a, int b) { return a > b ? a : b; }   int main() {     int n, m;     int i, j;     string s;     cin >> n >> m;     for (i = 0; i < n; ++i) {       cin >> s;       for (j = 0; j < m; ++j) {         if (s[j] ==  W )           mat[i][j] = 0;         else           mat[i][j] = 1;       }     }     int left = -1, right = 101, top = -1, bot = 101;     int bcount = 0;     for (i = 0; i < n; ++i) {       for (j = 0; j < m; ++j) {         if (mat[i][j] == 1) {           ++bcount;           if (left == -1)             left = j;           else             left = min(left, j);           if (right == 101)             right = j;           else             right = max(right, j);           if (top == -1)             top = i;           else             top = min(top, i);           if (bot == 101)             bot = i;           else             bot = max(bot, i);         }       }     }     int c = 0;     if (bot == 101 && right == 101 && left == -1 && top == -1)       c = 1;     else if (bot == top && right == left)       c = 0;     else {       int hor = bot - top + 1;       int ver = right - left + 1;       int side = max(hor, ver);       if (side > n || side > m)         c = -1;       else {         c = side * side - bcount;       }     }     cout << c << endl;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   const int MOD = 998244353;   int fact[N], factinv[N];   int lgcput(int b, int p) {     int a = 1;     while (p) {       if (p & 1) {         a = (1LL * a * b) % MOD;       }       b = (1LL * b * b) % MOD;       p /= 2;     }     return a;   }   int inv(int x) { return lgcput(x, MOD - 2); }   int main() {     int n, k;     cin >> n >> k;     fact[0] = factinv[0] = 1;     for (int i = 1; i <= n; i++) {       fact[i] = (1LL * i * fact[i - 1]) % MOD;       factinv[i] = (1LL * inv(i) * factinv[i - 1]) % MOD;     }     int c = n - k;     if (k >= n) {       cout <<  0 ;       return 0;     }     int ans = 0;     for (int i = 0; i <= c; i++) {       int dead =           (1LL *            ((1LL * ((1LL * fact[c] * factinv[i]) % MOD) * factinv[c - i]) % MOD) *            lgcput(c - i, n)) %           MOD;       if (i & 1)         ans -= dead;       else         ans += dead;       if (ans < 0) ans += MOD;       if (ans >= MOD) ans -= MOD;     }     ans = (1LL * (1LL * (1LL * ans * fact[n] % MOD) * factinv[c] % MOD) *            factinv[n - c]) %           MOD;     if (k == 0) {       cout << ans;       return 0;     }     ans *= 2;     ans %= MOD;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int nMax = 200003;   int smen[nMax];   int main() {     cin.sync_with_stdio(false);     cin.tie(NULL);     int n, k, q, st, dr;     cin >> n >> k >> q;     int m = nMax - 3;     for (int i = 1; i <= n; i++) {       cin >> st >> dr;       smen[st]++;       smen[dr + 1]--;     }     for (int i = 1; i <= m; i++) {       smen[i] = smen[i - 1] + smen[i];     }     for (int i = 1; i <= m; i++) {       if (smen[i] >= k) {         smen[i] = 1;       } else {         smen[i] = 0;       }     }     for (int i = 1; i <= m; i++) {       smen[i] = smen[i - 1] + smen[i];     }     int x, y;     for (int i = 1; i <= q; i++) {       cin >> x >> y;       cout << smen[y] - smen[x - 1] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, long long> dp;   long long fastPow(long long a, long long b) {     long long ret = 1;     while (b) {       if (b & 1) ret = (ret * a) % 1000000007;       a = (a * a) % 1000000007;       b >>= 1;     }     return ret;   }   long long cc(long long y) {     if (dp.find(y) != dp.end()) return dp[y];     dp[y] = fastPow(2, y - 1);     for (int i = 2; i * i <= y; i++) {       if (!(y % i)) {         dp[y] = (dp[y] - cc(i) + 1000000007) % 1000000007;         if (i != y / i) {           dp[y] = (dp[y] - cc(y / i) + 1000000007) % 1000000007;         }       }     }     dp[y]--;     return dp[y];   }   int main() {     long long x, y;     cin >> x >> y;     if (!(y % x)) {       y /= x;       if (y == 1) {         cout << 1 << endl;         return 0;       }       cout << cc(y) << endl;       return 0;     }     cout << 0 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     int cases;     scanf( %d , &cases);     while (cases--) {       int n, p;       scanf( %d%d , &n, &p);       for (int i = 2; i <= n; i++) {         printf( %d %d n , 1, i);       }       for (int i = 2; i < n; i++) {         printf( %d %d n , i, i + 1);       }       printf( %d %d n , n, 2);       int count = 0, extra = 2 * n + p - 2 * (n - 1);       for (int i = 2; i <= n; i++) {         for (int j = i + 2; j <= n; j++) {           if (i == 2 && j == n) break;           printf( %d %d n , i, j);           count++;           if (count == extra) goto here;         }       }     here:       continue;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int p[31111], dp[31111][800];   int main() {     int i, j, n, d, u;     scanf( %d%d , &n, &d);     for (i = 0; i < n; i++) {       scanf( %d , &u);       p[u]++;     }     for (i = 0; i <= 30000; i++) {       for (j = 0; j <= 650; j++) {         dp[i][j] = -10000000;       }     }     int ans = dp[d][300] = p[d];     for (i = d + 1; i <= 30000; i++) {       for (j = 1; j <= 600; j++) {         int pre = i - j - d + 300;         if (pre < 0) break;         if (pre >= i) continue;         dp[i][j] = max(dp[pre][j], max(dp[pre][j + 1], dp[pre][j - 1])) + p[i];         ans = max(ans, dp[i][j]);       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());   int dx[]{-1, 0, 0, 1};   int dy[]{-1, -1, 1, 1};   void solve() {     string str;     cin >> str;     cout << str;     reverse(str.begin(), str.end());     cout << str <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     solve();     cerr <<  Time elapsed:   << 1.0 * clock() / CLOCKS_PER_SEC <<  s. n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace FastIO {   const int L = (1 << 20);   char buf[L], *S, *T;   inline char getchar() {     if (S == T) {       T = (S = buf) + fread(buf, 1, L, stdin);       if (S == T) return EOF;     }     return *S++;   }   inline int read() {     int s = 0, f = 1;     char t = getchar();     while ( 0  > t || t >  9 ) {       if (t ==  - ) f = -1;       t = getchar();     }     while ( 0  <= t && t <=  9 ) {       s = (s << 1) + (s << 3) + t -  0 ;       t = getchar();     }     return s * f;   }   }  // namespace FastIO   using FastIO::read;   const int N = 55;   const int Mod = 998244353;   int dp[N][N][N * 2], sum, Sadd, Ssub;   int w[N], a[N], n, m;   int Inc(int x, int y) { return x + y >= Mod ? x + y - Mod : x + y; }   int Dec(int x, int y) { return x - y < 0 ? x - y + Mod : x - y; }   int Mul(int x, int y) { return (long long)x * y % Mod; }   int Fpow(int a, int b) {     int ans = 1;     while (b) {       if (b & 1) ans = Mul(ans, a);       b >>= 1;       a = Mul(a, a);     }     return ans;   }   int Inv(int x) { return Fpow(x, Mod - 2); }   void Dp(int c) {     memset(dp, 0, sizeof(dp));     dp[0][0][0] = 1;     for (int i = 0; i < m; i++) {       for (int k = 0; k <= i; k++) {         int now = (a[c] ? w[c] + k : w[c] - k);         if (now < 0) continue;         for (int d = 0; d <= i; d++) {           if (!dp[i][k][d]) continue;           int Dw = sum + d - (i - d);           Dw = Inv(Dw);           int Up_add = Sadd + d;           int Up_sub = Ssub - (i - d);           if (a[c]) {             dp[i + 1][k + 1][d + 1] =                 Inc(dp[i + 1][k + 1][d + 1], Mul(dp[i][k][d], Mul(now, Dw)));             dp[i + 1][k][d + 1] =                 Inc(dp[i + 1][k][d + 1], Mul(dp[i][k][d], Mul(Up_add - now, Dw)));             dp[i + 1][k][d] =                 Inc(dp[i + 1][k][d], Mul(dp[i][k][d], Mul(Up_sub, Dw)));           } else {             dp[i + 1][k + 1][d] =                 Inc(dp[i + 1][k + 1][d], Mul(dp[i][k][d], Mul(now, Dw)));             dp[i + 1][k][d + 1] =                 Inc(dp[i + 1][k][d + 1], Mul(dp[i][k][d], Mul(Up_add, Dw)));             dp[i + 1][k][d] =                 Inc(dp[i + 1][k][d], Mul(dp[i][k][d], Mul(Up_sub - now, Dw)));           }         }       }     }     int Ans = 0;     for (int k = 0; k <= m; k++) {       int now = (a[c] ? w[c] + k : w[c] - k);       if (now < 0) continue;       for (int d = 0; d <= m; d++) {         Ans = Inc(Ans, Mul(now, dp[m][k][d]));       }     }     cout << Ans <<   n ;   }   int main() {     n = read();     m = read();     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = 1; i <= n; i++) {       w[i] = read();       if (a[i])         Sadd += w[i];       else         Ssub += w[i];       sum += w[i];     }     for (int i = 1; i <= n; i++) Dp(i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a;     scanf( %d %d %*d , &n, &a);     map<long long, int> cnt1;     map<pair<int, int>, int> cnt2;     long long ans = 0;     for (int i = 0; i < n; ++i) {       int vx, vy;       scanf( %*d %d %d , &vx, &vy);       long long v = 1LL * a * vx - vy;       ans += cnt1[v];       ans -= cnt2[{vx, vy}];       ++cnt1[v];       ++cnt2[{vx, vy}];     }     printf( %lld n , ans * 2);   }
#include <bits/stdc++.h>   using namespace std;   long long L[200005], R[200005], U[200005], D[200005];   long long n;   string S;   long long x, y, sx = 0, sy = 0;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> S >> x >> y;     S =  _  + S;     L[0] = R[0] = U[0] = D[0] = 0;     for (long long i = 1; i <= n; i++) {       L[i] = L[i - 1];       R[i] = R[i - 1];       D[i] = D[i - 1];       U[i] = U[i - 1];       if (S[i] ==  L )         L[i]++, sx--;       else if (S[i] ==  R )         R[i]++, sx++;       else if (S[i] ==  U )         U[i]++, sy++;       else if (S[i] ==  D )         D[i]++, sy--;     }     if (sx == x && sy == y) {       cout << 0;       return 0;     }     if ((sx + sy + x + y) % 2 != 0) {       cout << -1;       return 0;     }     long long s_ind = 1, g_ind = n + 1;     while (g_ind > s_ind) {       long long len = (g_ind + s_ind) / 2;       bool b = 0;       for (long long j = len; j <= n; j++) {         long long l = L[n] - L[j] + L[j - len], r = R[n] - R[j] + R[j - len],                   u = U[n] - U[j] + U[j - len], d = D[n] - D[j] + D[j - len];         long long curx = r - l, cury = u - d;         if (abs(curx - x) + abs(cury - y) <= len) {           b = 1;           break;         }       }       if (b)         g_ind = len;       else         s_ind = len + 1;     }     if (s_ind <= n)       cout << s_ind;     else       cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 500023;   bool vis[N];   vector<int> adj[N];   void solve() {     long long int n;     cin >> n;     vector<long long int> v;     for (long long int i = 0; i < n; i++) {       long long int c;       cin >> c;       v.push_back(c);     }     sort((v).begin(), (v).end());     long long int ans = 0;     if (v[2] != v[1]) {       for (int i = 2; i < n; i++) {         if (v[i] == v[2])           ans++;         else           break;       }     } else if ((v[2] == v[1]) && (v[1] != v[0])) {       long long int count = 0;       for (int i = 1; i < n; i++) {         if (v[i] == v[1])           count++;         else           break;       }       ans = (count * (count - 1)) / 2;     } else {       long long int count = 0;       for (int i = 0; i < n; i++) {         if (v[i] == v[0])           count++;         else           break;       }       ans = (count * (count - 1) * (count - 2)) / 6;     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     int t = 0;     while (t++ < T) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long fact(int x) {     long long ans = 0;     while (x > 0) {       ans += x;       x--;     }     return ans;   }   int main() {     int n;     cin >> n;     vector<vector<char> > a(n, vector<char>(n));     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) cin >> a[i][j];     vector<int> ansi(n);     vector<int> ansj(n);     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++)         if (a[i][j] ==  C ) {           ansi[i]++;           ansj[j]++;         }     long long count = 0;     long long ans = 0;     for (int i = 0; i < n; i++) count += fact(ansi[i] - 1);     ans += count;     count = 0;     for (int i = 0; i < n; i++) count += fact(ansj[i] - 1);     ans += count;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, ans, a[300010];   bool check(int mid) {     int pre = mid + a[1] >= m ? 0 : a[1];     for (int i = 2; i <= n; i++) {       if (a[i] + mid < pre) return false;       if (a[i] <= pre)         continue;       else if (a[i] + mid >= m && (a[i] + mid) % m >= pre)         continue;       pre = a[i];     }     return true;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     int l = 0, r = m - 1;     while (l <= r) {       int mid = (l + r) >> 1;       if (check(mid))         ans = mid, r = mid - 1;       else         l = mid + 1;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define int unsigned long long      const int N = 100010;   int n, a[N];      signed main(void)   {       ios::sync_with_stdio(false);       map <int, int> mp;       int T;       cin >> T;       while(T--)       {           mp.clear();           int res = 0;           int n;           cin >> n;           for(int i = 1; i <= n; i++)           {               cin >> a[i];               res += mp[a[i]] * (n - i + 1);               mp[a[i]] += i;           }           cout << res << endl;       }       return 0;   }   /*   ————————————————   版权声明：本文为CSDN博主「zhbbbb！」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。   原文链接：https://blog.csdn.net/zhbbbbbb/article/details/117330722*/
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,fast-math,unroll-loops )   using namespace std;   const int maxn = 2e5 + 50;   inline char nc() {     static char buf[100000], *p1 = buf, *p2 = buf;     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)                ? EOF                : *p1++;   }   inline int read() {     char ch = nc();     int sum = 0;     while (!(ch >=  0  && ch <=  9 )) ch = nc();     while (ch >=  0  && ch <=  9 ) sum = sum * 10 + ch - 48, ch = nc();     return sum;   }   int t, n;   string str;   int sum1[maxn], sum2[maxn];   map<pair<int, int>, int> mp;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> t;     while (t--) {       cin >> n >> str;       str =      + str;       n++;       for (int i = 1; i <= n; i++)         sum1[i] = sum1[i - 1] + (str[i] ==  L ) - (str[i] ==  R ),         sum2[i] = sum2[i - 1] + (str[i] ==  U ) - (str[i] ==  D );       int ans = 0x3f3f3f3f, l = 0, r = 0;       mp.clear();       for (int i = 1; i <= n; i++) {         if (mp[make_pair(sum1[i], sum2[i])] != 0) {           int tmp = mp[make_pair(sum1[i], sum2[i])];           if (i - tmp < ans) ans = i - tmp, l = tmp + 1, r = i;         }         mp[make_pair(sum1[i], sum2[i])] = i;       }       if (ans == 0x3f3f3f3f)         printf( -1 n );       else         printf( %d %d n , l - 1, r - 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int m;   long long n;   long long deg[1001001], result;   vector<vector<int> > e;   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       int a, b;       scanf( %d%d , &a, &b);       deg[a]++;       deg[b]++;     }     result = 0;     for (int i = 1; i <= n; i++) result += (n - 1 - deg[i]) * deg[i];     result /= 2;     result = n * (n - 1) * (n - 2) / 6 - result;     cout << result;   }
#include <bits/stdc++.h>   const int MAXN = 1e5 + 19;   int qpow(int a, int b, int p) {     int res = 1;     while (b) {       if (b & 1) res = (long long)res * a % p;       a = (long long)a * a % p, b >>= 1;     }     return res;   }   int n, m, k, p;   int fa[MAXN], size[MAXN];   int getf(int node) {     return fa[node] == node ? node : fa[node] = getf(fa[node]);   }   int main() {     std::scanf( %d%d%d , &n, &m, &p);     for (int i = 1; i <= n; ++i) fa[i] = i, size[i] = 1;     for (int i = 1; i <= m; ++i) {       int u, v;       std::scanf( %d%d , &u, &v);       if (getf(u) != getf(v)) {         size[getf(v)] += size[getf(u)];         fa[getf(u)] = getf(v);       }     }     int ans = 1;     for (int i = 1; i <= n; ++i)       if (fa[i] == i) ++k, ans = (long long)ans * size[i] % p;     if (k >= 2)       ans = (long long)ans * qpow(n, k - 2, p) % p;     else       ans = 1;     std::printf( %d n , ans % p);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<long long int> vec1, vec2;     vector<long long int>::iterator it;     long long int n, a, sz, s1 = 0, s2 = 0, s3 = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a;       s1 += a;     }     n--;     for (int i = 0; i < n; i++) {       cin >> a;       s2 += a;     }     n--;     for (int i = 0; i < n; i++) {       cin >> a;       s3 += a;     }     cout << s1 - s2 << endl << s2 - s3;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 2000000000;   const int maxn = 1000005;   int n;   int a[maxn];   bool vis[maxn];   int main() {     long long ans = 0LL;     scanf( %d , &n);     for (int i = n; i >= 0; i--) {       if (vis[i]) continue;       int t = 0, s = 0;       for (int j = 0; j < 20; j++)         if (i & (1 << j)) s = j;       for (int j = s - 1; j >= 0; j--)         if (!(i & (1 << j))) t |= (1 << j);       a[i] = t, a[t] = i;       vis[i] = vis[t] = 1;       ans += 2 * (i ^ t);     }     printf( %I64d n , ans);     for (int i = 0; i < n; i++) printf( %d  , a[i]);     printf( %d n , a[n]);     return 0;   }