malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long int, long long int>> v1;   int main() {     long long int n, i, A[300005], minn, t1, a1, i1;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> A[i];       v1.push_back(make_pair(A[i], i));     }     minn = 10000000000;     for (i = 2; i <= n; i++) {       t1 = min(A[1], A[i]) / (i - 1);       if (t1 < minn) minn = t1;     }     for (i = n - 1; i >= 1; i--) {       t1 = min(A[n], A[i]) / (n - i);       if (t1 < minn) minn = t1;     }     sort(v1.begin(), v1.end());     a1 = v1[0].first;     i1 = v1[0].second;     for (i = 1; i < v1.size(); i++) {       t1 = min(a1, v1[i].first) / (abs(i1 - v1[i].second));       if (t1 < minn) minn = t1;     }     cout << minn << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 2e5 + 10;   const long long oo = 1e18;   char s[maxN];   long long cost[maxN][2];   int main() {     int test;     scanf( %d , &test);     while (test--) {       int n, a, b;       scanf( %d%d%d%*c , &n, &a, &b);       gets(s);       cost[0][0] = b;       cost[0][1] = oo;       for (int i = 0; i < n; i++) {         if (s[i] ==  0 ) {           cost[i + 1][0] = min(cost[i][0] + a + b, cost[i][1] + a * 2 + b);           cost[i + 1][1] = min(cost[i][0] + 2 * (a + b), cost[i][1] + a + b * 2);         } else {           cost[i + 1][1] = cost[i][1] + a + b * 2;           cost[i + 1][0] = oo;         }       }       printf( %lld n , cost[n][0]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[100001], g[100001], h[100001], m;   set<int> events[100001];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) events[i].clear();     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), events[a[i]].insert(i);     m = 0;     bool ok = true;     for (int i = 1; i <= n; ++i)       if (!events[i].empty())         if (events[i].find(i) == events[i].end()) {           ok = false;           break;         }     if (!ok) {       printf( -1 n );       return 0;     }     for (int i = 1; i <= n; i++)       if (!events[i].empty()) {         h[++m] = i;         for (set<int>::iterator itr = events[i].begin(); itr != events[i].end();              ++itr)           g[*itr] = m;       }     printf( %d n , m);     for (int i = 1; i <= n; i++) printf( %d  , g[i]);     printf(  n );     for (int i = 1; i <= m; i++) printf( %d  , h[i]);     printf(  n );   }
#include<bits/stdc++.h>   using namespace std;   long long a,b,c,d,e,i,j,ii,jj,zx,xc,tes,t,f[200009],A[200009],B[200009],rg[200009][20],rgx[200009][20],lf[200009][20],lfx[200009][20],P[200009],pas;   stack <long long> st;   set <long long> s;   set <long long>::iterator it,lft,rgt;   long long uprg(long long q, long long w){    if(q>=w) return 0;    long long jm=0;    long long h=0;    for(h=18; h>=0; h--){     if(rg[q][h]!=0&&rg[q][h]<w){      jm+=rgx[q][h];      q=rg[q][h];     }    }    jm+=rgx[q][0];    return jm;   }   long long uplf(long long q, long long w){    if(w<=q) return 0;    long long jm=0;    long long h=0;    for(h=19; h>=0; h--){     if(lf[w][h]!=0&&lf[w][h]>q){      jm+=lfx[w][h];      w=lf[w][h];     }    }    jm+=lfx[w][0];    return jm;   }   long long fun(long long q, long long w){    if(q>=w) return 0;    long long jm=0;    long long h=0;    for(h=18; h>=0; h--){     if(rg[q][h]!=0&&rg[q][h]<=w){      jm+=rgx[q][h];      q=rg[q][h];     }    }    if(q==w) return jm;    jm+=uplf(q,w);    return jm;   }   int main(){    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);    cin>>a>>tes;    for(i=1; i<=a; i++) cin>>f[i];    for(i=1; i<=a; i++) cin>>A[i];    for(i=1; i<=a; i++) cin>>B[i];    while(st.size()) st.pop();    st.push(a+1);    f[a+1]=a+2;    for(i=a; i>=1; i--){     while(st.size()>0&&f[st.top()]<f[i]) st.pop();     if(st.size()==0){           }else{      rg[i][0]=st.top();      rgx[i][0]=min(B[i],A[i]+uprg(i+1,st.top()));     }     for(j=1; j<=18; j++){      rg[i][j]=rg[rg[i][j-1]][j-1];      rgx[i][j]=rgx[i][j-1]+rgx[rg[i][j-1]][j-1];     }     st.push(i);    }    while(st.size()) st.pop();    for(i=1; i<=a; i++){     while(st.size()>0&&f[st.top()]<f[i]) st.pop();     if(st.size()==0){           }else{      lf[i][0]=st.top();      lfx[i][0]=A[st.top()]+uprg(st.top()+1,i);     }     for(j=1; j<=18; j++){      lf[i][j]=lf[lf[i][j-1]][j-1];      lfx[i][j]=lfx[i][j-1]+lfx[lf[i][j-1]][j-1];     }     st.push(i);    }    s.insert(1);    s.insert(a+1);    P[1]=fun(1,a+1);    pas+=P[1];    for(t=1; t<=tes; t++){     cin>>c;     if(c==1){      cout<<pas<<endl;      continue;     }     it=s.lower_bound(c);     if(it==s.end()||(*it)!=c){      P[c]=fun(c,(*it));      pas+=P[c];      lft=it;lft--;      pas-=P[(*lft)];      P[(*lft)]=fun((*lft),c);      pas+=P[(*lft)];      s.insert(c);     }else{      lft=it;lft--;      pas-=P[(*lft)];      rgt=it;rgt++;      pas-=P[c];      P[(*lft)]=fun((*lft),(*rgt));      pas+=P[(*lft)];      s.erase(it);     }     cout<<pas<<endl;    }    P[0]=2*6;    pas=P[0]+5;    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int solve(int n, int m, int k) {     if (n > m) return 0;     if (n == 0) return min(m + 1, (1 << (k + 1)));     if ((1 << k) & n) {       int c = solve(n - (1 << k), m - (1 << k), k - 1);       if (c == (1 << k))         return (1 << (k + 1));       else         return c;     } else {       int z = solve(n, m - (1 << k), k - 1);       if (z == (1 << k))         return 2 * z;       else {         int c = solve(n, m, k - 1);         if (c == (1 << k))           return (1 << k) + z;         else           return c;       }     }   }   void solve() {     int n, m;     cin >> n >> m;     cout << solve(n, m, 29) <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   bool f = 0;   const double eps = 1e-8;   int n;   struct point {     double x, y;   } p[100010];   inline int rd() {     int x = 0;     bool f = 0;     char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) f = 1;       c = getchar();     }     while (isdigit(c)) {       x = (x << 1) + (x << 3) + (c ^ 48);       c = getchar();     }     return f ? -x : x;   }   inline bool valid(double x) {     double l = -(double)1e18, r = (double)1e18, dlt;     for (register int i = 1; i <= n; ++i) {       if (p[i].y > x + x) return 0;       dlt = sqrt(p[i].y * (2 * x - p[i].y));       l = max(l, p[i].x - dlt);       r = min(r, p[i].x + dlt);     }     return (r - l + eps >= 0.0);   }   int main() {     n = rd();     for (register int i = 1; i <= n; ++i) {       p[i].x = (double)rd();       p[i].y = (double)rd();       if (p[i].y < 0.0) f = 1;     }     if (f == 1)       for (register int i = 1; i <= n; ++i) {         p[i].y = -p[i].y;         if (p[i].y < 0.0) {           puts( -1 );           return 0;         }       }     int t = 0;     register double l = 0.0, r = (double)1e18, mid;     while (t <= 300) {       mid = (l + r) / 2.0;       ++t;       valid(mid) ? r = mid : l = mid;     }     printf( %.10lf , l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const long long inf = 2e9 + 10;   template <typename T1, typename T2>   static void relax(T1 &x, T2 y) {     if (x > y) x = y;   }   template <typename T1, typename T2>   static void gain(T1 &x, T2 y) {     if (x < y) x = y;   }   long long powmod(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return res;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   inline void add(int &x, int y) {     x += y;     if (x >= mod) x -= mod;   }   inline void sub(int &x, int y) {     x -= y;     if (x < 0) x += mod;   }   const int maxl = 2e3 + 3;   int m, d;   string a, b;   int dp[maxl][maxl][2];   int solve(string s) {     int n = (int)s.length();     for (int(i) = 0; (i) < (int)(n + 1); ++(i))       for (int(j) = 0; (j) < (int)(m); ++(j))         for (int(k) = 0; (k) < (int)(2); ++(k)) dp[i][j][k] = 0;     dp[0][0][1] = 1;     for (int(i) = 0; (i) < (int)(n); ++(i))       for (int(j) = 0; (j) < (int)(m); ++(j))         for (int(k) = 0; (k) < (int)(2); ++(k))           for (int dgt = 0; dgt <= (k ? int(s[i] -  0 ) : 9); ++dgt) {             if ((i & 1) && dgt != d) continue;             if (!(i & 1) && dgt == d) continue;             int ni = i + 1;             int nj = ((j * 10 + dgt) % m);             int nk = k && (dgt == int(s[i] -  0 ));             add(dp[ni][nj][nk], dp[i][j][k]);           }     int ans = 0;     for (int(k) = 0; (k) < (int)(2); ++(k)) add(ans, dp[n][0][k]);     return ans;   }   bool ok(string s) {     int n = (int)s.length();     int rem = 0;     for (int(i) = 0; (i) < (int)(n); ++(i)) {       int dgt = int(s[i] -  0 );       if ((i & 1) && dgt != d) return false;       if (!(i & 1) && dgt == d) return false;       rem = (rem * 10 + dgt) % m;     }     return !rem;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cin >> m >> d;     cin >> a;     cin >> b;     int ans = 0;     add(ans, solve(b));     sub(ans, solve(a));     add(ans, ok(a));     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[200010];   int main() {     cin.tie(0);     ios_base::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     int f = 0;     for (int i = 1; i < n; i++)       if (a[i] != a[i - 1]) {         f = 1;         break;       }     if (f == 0) {       if (a[0] == 0) {         cout <<  YES  << endl;         for (int i = 0; i < n; i++) cout <<  1  <<    ;         exit(0);       }       cout <<  NO  << endl;       exit(0);     }     long long mx = 0, mxer = 0;     for (int i = 0; i < n; i++)       if (a[i] > mx) mx = a[mxer = i];     while (true) {       int x = mxer - 1;       if (x < 0) x += n;       if (a[x] == a[mxer])         mxer = x;       else         break;     }     int flag = 1;     for (int i = 1; i < n; i++) {       int x = mxer - 1;       if (x < 0) x += n;       if (flag && a[x] == 0) {         a[x] += a[mxer];         flag = 0;       }       a[x] += a[mxer];       mxer = x;     }     cout <<  YES  << endl;     for (int i = 0; i < n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int(a), int(b)) { return ((a) % (b) ? gcd((b), (a) % (b)) : (b)); }   long long lgcd(long long(a), long long(b)) {     return ((a) % (b) ? gcd((b), (a) % (b)) : (b));   }   int lcm(int a, int b) { return (a) / gcd((a), (b)) * b; }   long long llcm(long long a, long long b) { return (a) / lgcd((a), (b)) * b; }   int n, m, ans[100010], crime[100010], notcrime[100010];   int main() {     memset(ans, 0, sizeof(ans));     memset(crime, 0, sizeof(crime));     memset(notcrime, 0, sizeof(notcrime));     scanf( %d%d , &n, &m);     getchar();     for (int i = 1; i <= n; i++) {       char c;       int temp;       scanf( %c%d , &c, &temp);       getchar();       if (c ==  + ) {         crime[temp]++;         ans[i] = temp;       } else {         notcrime[temp]++;         ans[i] = -temp;       }     }     int nnc = 0;     for (int i = 1; i <= n; i++) nnc += notcrime[i];     int nc = 0;     bool cc[100010];     memset(cc, false, sizeof(cc));     for (int i = 1; i <= n; i++) {       if (crime[i] + nnc - notcrime[i] == m) {         cc[i] = true;         nc++;       }     }     for (int i = 1; i <= n; i++) {       if (ans[i] > 0) {         if (cc[((ans[i]) > 0 ? (ans[i]) : -(ans[i]))]) {           if (nc > 1)             printf( Not defined n );           else             printf( Truth n );         } else           printf( Lie n );       } else {         if (cc[((ans[i]) > 0 ? (ans[i]) : -(ans[i]))]) {           if (nc == 1)             printf( Lie n );           else             printf( Not defined n );         } else           printf( Truth n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[] = {-1, 0, 1, 0};   const int dy[] = {0, -1, 0, 1};   const int dx8[] = {-1, 0, 1, 0, 1, 1, -1, -1};   const int dy8[] = {0, -1, 0, 1, 1, -1, 1, -1};   void solve() {     long long n;     cin >> n;     vector<long long> a(n);     vector<vector<long long>> dp(n, vector<long long>(n));     vector<vector<long long>> sum(n, vector<long long>(n));     for (long long i = 0; i < n; i++) cin >> a[i];     sort(a.begin(), a.end());     vector<long long> s(n), l(n);     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < n; j++) {         if (a[i] >= 2 * a[j]) {           l[i] = j;           s[i]++;         }       }     }     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < n; j++) {         if (j == 0) {           dp[i][j] = 1;           long long x = i - 1 >= 0 ? sum[i - 1][j] : 0;           sum[i][j] = x + dp[i][j];           sum[i][j] %= 998244353;           continue;         }         if (s[i] - j + 1 > 0) {           dp[i][j] =               (dp[i][j - 1] * (s[i] - j + 1)) % 998244353 + sum[l[i]][j - 1];           dp[i][j] %= 998244353;         } else           dp[i][j] = 0;         long long x = i - 1 >= 0 ? sum[i - 1][j] : 0;         sum[i][j] = x + dp[i][j];         sum[i][j] %= 998244353;       }     }     cout << dp[n - 1][n - 1] <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();   }
#include <bits/stdc++.h>   using namespace std;   map<int, map<int, int> > m;   long long int lol(long long int a, long long int r) {     if (a >= 0 && r <= 0) return a;     if (a <= 0 && r >= 0) return a;     return a % r;   }   int main() {     long long int a, b;     cin >> a >> b;     string s;     cin >> s;     long x = 0;     long y = 0;     if (a == 0 && b == 0) {       cout <<  Yes  << endl;       return 0;     }     for (long i = 0; i < s.size(); i++) {       if (s[i] ==  L ) x--;       if (s[i] ==  R ) x++;       if (s[i] ==  U ) y++;       if (s[i] ==  D ) y--;     }     long p = 2;     long w = 0;     long q = 0;     int d = 0;     for (long i = 0; i < s.size(); i++) {       if (s[i] ==  L ) w--;       if (s[i] ==  R ) w++;       if (s[i] ==  U ) q++;       if (s[i] ==  D ) q--;       long long int u = a - w;       long long int e = b - q;       if (x != 0) {         if (y != 0) {           long long int v = u / x;           long long int z = e / y;           if (v == z && v >= 0 && u % x == 0 && e % y == 0) d = 1;         } else {           long long int v = a / x;           if (e == 0 && v >= 0 && u % x == 0) d = 1;         }       } else {         if (y != 0) {           long long int z = e / y;           if (z >= 0 && u == 0 && e % y == 0) d = 1;         } else {           if (u == 0 && e == 0) d = 1;         }       }     }     if (d == 1)       cout <<  Yes  << endl;     else       cout <<  No  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int V = 100100;   int l[V], r[V], a[V], ret, n;   int main() {     while (~scanf( %d , &n)) {       ret = 0;       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       for (int i = 1; i <= n; i++) l[i] = r[i] = i;       for (int i = 1; i <= n; i++) {         while (l[i] != 1 && a[l[i] - 1] < a[i]) l[i] = l[l[i] - 1];         if (l[i] != 1) ret = max(ret, a[i] ^ a[l[i] - 1]);       }       for (int i = n; i >= 1; i--) {         while (r[i] != n && a[r[i] + 1] < a[i]) r[i] = r[r[i] + 1];         if (r[i] != n) ret = max(ret, a[i] ^ a[r[i] + 1]);       }       printf( %d n , ret);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 17;   int n;   vector<int> adj[(1 << MAX_N) + 9];   bool used[(1 << MAX_N) + 9];   int cnt[(1 << MAX_N) + 9];   vector<int> vRoot;   vector<int> ans;   void buildCnt(int x) {     used[x] = true;     cnt[x] = 1;     for (int y : adj[x]) {       if (!used[y]) {         buildCnt(y);         cnt[x] += cnt[y];       }     }     used[x] = false;   }   void findRoot(int x, vector<int>& vRoot) {     used[x] = true;     for (int y : adj[x]) {       if (!used[y]) {         findRoot(y, vRoot);       }     }     if ((1 << n) - 2 - cnt[x] == (1 << n - 1) - 1) {       vRoot.push_back(x);     } else {       for (int y : adj[x]) {         if (!used[y]) {           if (cnt[y] == (1 << n - 1) - 1) {             vRoot.push_back(x);             break;           }         }       }     }     used[x] = false;   }   bool checkTree1(int x, int depth) {     used[x] = true;     bool result = false;     if (cnt[x] != (1 << depth) - 1) {       result = false;     } else if (depth == 1) {       result = true;     } else {       result = true;       for (int y : adj[x]) {         if (!used[y]) {           if (!checkTree1(y, depth - 1)) {             result = false;             break;           }         }       }     }     used[x] = false;     return result;   }   int checkTree2(int x, int depth) {     used[x] = true;     int result = -1;     if (cnt[x] != (1 << depth) - 2) {       result = -1;     } else if (depth == 2) {       result = x;     } else {       vector<pair<int, int>> children;       for (int y : adj[x]) {         if (!used[y]) {           children.push_back(make_pair(cnt[y], y));         }       }       sort(children.begin(), children.end());       if (children.size() == 2) {         int tmp = checkTree2(children[0].second, depth - 1);         if (tmp != -1 && checkTree1(children[1].second, depth - 1)) {           result = tmp;         } else {           result = -1;         }       } else if (children.size() == 3) {         if (checkTree1(children[0].second, depth - 2) &&             checkTree1(children[1].second, depth - 2) &&             checkTree1(children[2].second, depth - 1)) {           result = x;         } else {           result = -1;         }       } else {         result = -1;       }     }     used[x] = false;     return result;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 1; i <= (1 << n) - 3; i++) {       int x;       int y;       cin >> x >> y;       adj[x].push_back(y);       adj[y].push_back(x);     }     buildCnt(1);     findRoot(1, vRoot);     for (int root : vRoot) {       buildCnt(root);       int x = checkTree2(root, n);       if (x != -1) {         ans.push_back(x);       }     }     sort(ans.begin(), ans.end());     cout << ans.size() <<   n ;     for (int x : ans) {       cout << x <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, maxx, idx, max1, s;   int main(int argc, char *argv[]) {     pair<int, int> a[10000];     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i].first;       a[i].second = 0;     }     maxx = 0;     max1 = 0;     for (int i = 0; i < n; i++) {       if (a[i].first > maxx) {         max1 = maxx;         maxx = a[i].first;         idx = i;       } else if (max1 < a[i].first)         max1 = a[i].first;     }     cout << idx + 1 <<     << max1 << endl;     return EXIT_SUCCESS;   }
#include <bits/stdc++.h>   using namespace std;   long long z, mn, mx, sum, ans, k, pos, pos1, r, xx, yy, zz, n, m, x, y;   vector<int> v;   bool OK[1000002], KO[1000002], zoom;   int b[100003], c[100002];   map<char, int> mp, mr;   set<int> st;   int main() {     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> x >> y >> k;       cout << ((k + 1) / 2 * x) - (k / 2 * y) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     long long int n = 0ll, k = 0ll, p = 0ll, pn = 0ll, even = 0ll, odd = 0ll;     while (cin >> n) {       cin >> k >> p;       if (k == 0) {         for (long long int i = 0; i < p; i++) {           cin >> pn;           cout <<  . ;         }         cout << endl;       } else {         if (n % 2 == 0) {           if (k >= (n >> 1)) {             even = 2;             k -= (n >> 1);             odd = n + 1 - (k << 1);           } else {             odd = n + 1;             even = n + 2 - (k << 1);           }           for (int i = 0; i < p; i++) {             cin >> pn;             if (pn % 2 == 0) {               if (pn >= even) {                 cout <<  X ;               } else {                 cout <<  . ;               }             } else {               if (pn >= odd) {                 cout <<  X ;               } else {                 cout <<  . ;               }             }           }           cout << endl;         } else {           n--;           k--;           if (k >= (n >> 1)) {             even = 2;             k -= (n >> 1);             odd = n + 1 - (k << 1);           } else {             odd = n + 1;             even = n + 2 - (k << 1);           }           for (int i = 0; i < p; i++) {             cin >> pn;             if (pn == n + 1) {               cout <<  X ;             } else if (pn % 2 == 0) {               if (pn >= even) {                 cout <<  X ;               } else {                 cout <<  . ;               }             } else {               if (pn >= odd) {                 cout <<  X ;               } else {                 cout <<  . ;               }             }           }           cout << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   int fin(int rem) {     for (auto p : mp) {       if (p.first >= rem) return p.first;     }     return -1;   }   int main() {     long long ans = 0, rem = 0, p, x, y, n, RES = 1e9;     cin >> n >> x >> y;     long long a[] = {x, x, x, x, y, y};     sort(a, a + 6);     do {       mp.clear();       ans = 0;       for (int i = 0; i < 6; ++i) {         if ((x = fin(a[i])) == -1) {           ++ans;           ++mp[n - a[i]];         } else {           ++mp[x - a[i]];           if (!--mp[x]) mp.erase(x);         }       }       RES = min(RES, ans);     } while (next_permutation(a, a + 6));     cout << RES;   }
#include <bits/stdc++.h>   using namespace std;   int sum[100005];   int main() {     int h1, h2, a, b, k, x;     cin >> h1 >> h2 >> a >> b;     int num = h1 + a * 8;     if (num >= h2)       x = 0;     else if (a <= b)       x = -1;     else {       x = 1;       num -= b * 12;       for (int i = 1;; i++) {         num += a * 12;         if (num >= h2)           break;         else {           x++;           num -= b * 12;         }       }     }     cout << x << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, k;     scanf( %d %d , &n, &k);     printf( %d n , 6 * n * k - k);     for (int i = 0; i < n; ++i) {       printf( %d %d %d %d n , 6 * i * k + k, 6 * i * k + 2 * k, 6 * i * k + 3 * k,              6 * i * k + 5 * k);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, fact[405], inv[405], dp[405][405], ans[405], n, dp2[405];   long long p;   long long exp(long long x, long long k) {     if (k == 0) return 1;     if (k % 2 == 1) return x * exp(x, k - 1) % p;     long long y = exp(x, k / 2);     return y * y % p;   }   int main() {     cin >> t >> p;     fact[0] = 1;     for (int i = 1; i < 405; ++i) {       fact[i] = i * fact[i - 1] % p;       inv[i] = exp(i, p - 2);     }     dp[0][0] = 1;     for (int i = 0; i <= 399; ++i)       for (int k = 1; k <= 400; ++k)         for (int j = 0; j <= 400 - k; ++j)           dp[j + k][i + 1] = (dp[j + k][i + 1] + fact[k] * dp[j][i]) % p;     dp2[1] = dp2[2] = 1;     for (int i = 3; i <= 400; ++i) {       dp2[i] = fact[i];       for (int j = 1; j < i; ++j)         dp2[i] = (p + dp2[i] - dp2[j] * fact[i - j] % p) % p;     }     for (int i = 1; i <= 400; ++i) {       ans[i] = fact[i];       for (int j = 3; j < i; ++j) ans[i] = (ans[i] + p - dp[i][j] * ans[j]) % p;       for (int j = 1; j <= i - 1; ++j)         ans[i] = (ans[i] + p - 2 * dp2[j] * fact[i - j] % p) % p;       ans[2] = 2;     }     for (int i = 0; i < t; ++i) {       int x;       cin >> x;       cout << ans[x] <<   n ;     }   }